Skip to content

Commit

Permalink
Comment includes only line number of the offense
Browse files Browse the repository at this point in the history
Request in ManageIQ#406 to remove addition "column" information about the offence
  • Loading branch information
europ committed Mar 6, 2018
1 parent 1fb4ca1 commit 5ba0ef1
Show file tree
Hide file tree
Showing 12 changed files with 318 additions and 2,763 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def offenses
SEVERITY_MAP[o["severity"]],
format_message(o),
f["path"],
format_locator(f, o)
format_line(f, o)
)
end
end.flatten
Expand All @@ -96,22 +96,13 @@ def format_cop_name(cop_name)
COP_URIS[cop_name] || cop_name
end

def format_locator(file, offense)
[format_line(file, offense), format_column(offense)].compact.join(", ").presence
end

def format_line(file, offense)
line = offense.fetch_path("location", "line")
line = offense.fetch_path("line")
return nil unless line
uri = File.join(line_uri, "blob", commits.last, file["path"]) << "#L#{line}"
"[Line #{line}](#{uri})"
end

def format_column(offense)
column = offense.fetch_path("location", "column")
column && "Col #{column}"
end

# TODO: Don't reuse the commit_uri. This should probably be its own URI.
def line_uri
branch.commit_uri.chomp("commit/$commit")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def filter_on_diff
@results["files"].each do |f|
f["offenses"].select! do |o|
o["severity"].in?(%w(error fatal)) ||
@diff_details[f["path"]].include?(o["location"]["line"])
@diff_details[f["path"]].include?(o["line"])
end
end
end
Expand Down
6 changes: 1 addition & 5 deletions app/workers/concerns/code_analysis_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ def run_all_linters
"message" => msg.msg,
"cop_name" => msg.runner,
"corrected" => false,
"location" => {
"line" => msg.line.position,
"column" => 0, # TODO: value cannot be obtained from Pronto::Message
"length" => msg.line.length,
}
"line" => msg.line.position
}
end
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
{
"severity": "error",
"message": "You don't need to use \"- end\" in Haml. Un-indent to close a block:\n- if foo?\n %strong Foo!\n- else\n Not foo.\n%p This line is un-indented, so it isn't part of the \"if\" block",
"location": {
"line": 3
}
"line": 3
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,21 @@
"message": "Freeze mutable objects assigned to constants.",
"cop_name": "Style/MutableConstant",
"corrected": false,
"location": {
"start_line": 2,
"start_column": 10,
"last_line": 6,
"last_column": 3,
"length": 78,
"line": 2,
"column": 10
}
"line": 2
},
{
"severity": "convention",
"message": "Align the elements of a hash literal if they span more than one line.",
"cop_name": "Layout/AlignHash",
"corrected": false,
"location": {
"start_line": 3,
"start_column": 5,
"last_line": 3,
"last_column": 20,
"length": 16,
"line": 3,
"column": 5
}
"line": 3
},
{
"severity": "convention",
"message": "Align the elements of a hash literal if they span more than one line.",
"cop_name": "Layout/AlignHash",
"corrected": false,
"location": {
"start_line": 4,
"start_column": 5,
"last_line": 4,
"last_column": 22,
"length": 18,
"line": 4,
"column": 5
}
"line": 4
}
]
}
Expand Down
Loading

0 comments on commit 5ba0ef1

Please sign in to comment.