Skip to content

Commit

Permalink
Add comments for lint errors in RuboCop sample project
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmeuli committed Jan 6, 2020
1 parent 9c69a93 commit 2d49739
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/linters/params/rubocop.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const extensions = ["rb"];

// Testing input/output for the Linter.lint function, with auto-fixing disabled
function getLintParams(dir) {
const resultsFile1 = `{"path":"file1.rb","offenses":[{"severity":"convention","message":"Redundant \`return\` detected.","cop_name":"Style/RedundantReturn","corrected":false,"location":{"start_line":4,"start_column":3,"last_line":4,"last_column":8,"length":6,"line":4,"column":3}}]}`;
const resultsFile2 = `{"path":"file2.rb","offenses":[{"severity":"warning","message":"Useless assignment to variable - \`x\`.","cop_name":"Lint/UselessAssignment","corrected":false,"location":{"start_line":3,"start_column":1,"last_line":3,"last_column":1,"length":1,"line":3,"column":1}}]}`;
const resultsFile1 = `{"path":"file1.rb","offenses":[{"severity":"convention","message":"Redundant \`return\` detected.","cop_name":"Style/RedundantReturn","corrected":false,"location":{"start_line":5,"start_column":3,"last_line":5,"last_column":8,"length":6,"line":5,"column":3}}]}`;
const resultsFile2 = `{"path":"file2.rb","offenses":[{"severity":"warning","message":"Useless assignment to variable - \`x\`.","cop_name":"Lint/UselessAssignment","corrected":false,"location":{"start_line":4,"start_column":1,"last_line":4,"last_column":1,"length":1,"line":4,"column":1}}]}`;
return {
// Strings that must be contained in the stdout of the lint command
stdoutParts: [resultsFile1, resultsFile2],
Expand All @@ -19,14 +19,14 @@ function getLintParams(dir) {
[
{
path: "file1.rb",
firstLine: 4,
lastLine: 4,
firstLine: 5,
lastLine: 5,
message: "Redundant `return` detected (Style/RedundantReturn)",
},
{
path: "file2.rb",
firstLine: 3,
lastLine: 3,
firstLine: 4,
lastLine: 4,
message: "Useless assignment to variable - `x` (Lint/UselessAssignment)",
},
],
Expand All @@ -37,8 +37,8 @@ function getLintParams(dir) {

// Testing input/output for the Linter.lint function, with auto-fixing enabled
function getFixParams(dir) {
const resultsFile1 = `{"path":"file1.rb","offenses":[{"severity":"convention","message":"Redundant \`return\` detected.","cop_name":"Style/RedundantReturn","corrected":true,"location":{"start_line":4,"start_column":3,"last_line":4,"last_column":8,"length":6,"line":4,"column":3}}]}`;
const resultsFile2 = `{"path":"file2.rb","offenses":[{"severity":"warning","message":"Useless assignment to variable - \`x\`.","cop_name":"Lint/UselessAssignment","corrected":false,"location":{"start_line":3,"start_column":1,"last_line":3,"last_column":1,"length":1,"line":3,"column":1}}]}`;
const resultsFile1 = `{"path":"file1.rb","offenses":[{"severity":"convention","message":"Redundant \`return\` detected.","cop_name":"Style/RedundantReturn","corrected":true,"location":{"start_line":5,"start_column":3,"last_line":5,"last_column":8,"length":6,"line":5,"column":3}}]}`;
const resultsFile2 = `{"path":"file2.rb","offenses":[{"severity":"warning","message":"Useless assignment to variable - \`x\`.","cop_name":"Lint/UselessAssignment","corrected":false,"location":{"start_line":4,"start_column":1,"last_line":4,"last_column":1,"length":1,"line":4,"column":1}}]}`;
return {
// Strings that must be contained in the stdout of the lint command
stdoutParts: [resultsFile1, resultsFile2],
Expand All @@ -50,8 +50,8 @@ function getFixParams(dir) {
[
{
path: "file2.rb",
firstLine: 3,
lastLine: 3,
firstLine: 4,
lastLine: 4,
message: "Useless assignment to variable - `x` (Lint/UselessAssignment)",
},
],
Expand Down
1 change: 1 addition & 0 deletions test/linters/projects/rubocop/file1.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

def method
# "Style/RedundantReturn" convention
return 'words'
end
1 change: 1 addition & 0 deletions test/linters/projects/rubocop/file2.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true

# "Lint/UselessAssignment" warning
x = 1

0 comments on commit 2d49739

Please sign in to comment.