Skip to content

Commit

Permalink
Merge pull request #528 from crystal-ameba/sort-sources-and-issues
Browse files Browse the repository at this point in the history
Sort sources and issues before passing them to the formatter
  • Loading branch information
Sija authored Dec 6, 2024
2 parents 29989b0 + 5aeda45 commit b96acc1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ameba/runner.cr
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ module Ameba
)
end

protected def initialize(rules, @sources, @formatter, @severity, @autocorrect = false, @version = nil)
protected def initialize(rules, sources, @formatter, @severity, @autocorrect = false, @version = nil)
@sources = sources.sort_by(&.path)
@rules =
rules.select { |rule| rule_runnable?(rule, @version) }
@unneeded_disable_directive_rule =
Expand Down Expand Up @@ -159,6 +160,10 @@ module Ameba

File.write(source.path, source.code) unless corrected_issues.empty?
ensure
missing_location = Crystal::Location.new(nil, 0, 0)
source.issues.sort_by! do |issue|
issue.location || missing_location
end
@formatter.source_finished source
end

Expand Down

0 comments on commit b96acc1

Please sign in to comment.