-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Adds the information about which Cops exactly caused an infinite loop
- Loading branch information
Showing
8 changed files
with
259 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module RuboCop | ||
module Cop | ||
module Test | ||
# This cop is only used to test infinite loop detection | ||
class AtoB < RuboCop::Cop::Base | ||
extend AutoCorrector | ||
|
||
def on_class(node) | ||
return unless /A/.match?(node.loc.name.source) | ||
|
||
add_offense(node.loc.name, message: 'A to B') do |corrector| | ||
autocorrect(corrector, node) | ||
end | ||
end | ||
alias on_module on_class | ||
|
||
private | ||
|
||
def autocorrect(corrector, node) | ||
corrector.replace(node.loc.name, node.loc.name.source.tr('A', 'B')) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module RuboCop | ||
module Cop | ||
module Test | ||
# This cop is only used to test infinite loop detection | ||
class BtoA < RuboCop::Cop::Base | ||
extend AutoCorrector | ||
|
||
def on_class(node) | ||
return unless /B/.match?(node.loc.name.source) | ||
|
||
add_offense(node.loc.name, message: 'B to A') do |corrector| | ||
autocorrect(corrector, node) | ||
end | ||
end | ||
alias on_module on_class | ||
|
||
private | ||
|
||
def autocorrect(corrector, node) | ||
corrector.replace(node.loc.name, node.loc.name.source.tr('B', 'A')) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module RuboCop | ||
module Cop | ||
module Test | ||
# This cop is only used to test infinite loop detection | ||
class BtoC < RuboCop::Cop::Base | ||
extend AutoCorrector | ||
|
||
def on_class(node) | ||
return unless /B/.match?(node.loc.name.source) | ||
|
||
add_offense(node.loc.name, message: 'B to C') do |corrector| | ||
autocorrect(corrector, node) | ||
end | ||
end | ||
alias on_module on_class | ||
|
||
private | ||
|
||
def autocorrect(corrector, node) | ||
corrector.replace(node.loc.name, node.loc.name.source.tr('B', 'C')) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module RuboCop | ||
module Cop | ||
module Test | ||
# This cop is only used to test infinite loop detection | ||
class CtoA < RuboCop::Cop::Base | ||
extend AutoCorrector | ||
|
||
def on_class(node) | ||
return unless /C/.match?(node.loc.name.source) | ||
|
||
add_offense(node.loc.name, message: 'C to A') do |corrector| | ||
autocorrect(corrector, node) | ||
end | ||
end | ||
alias on_module on_class | ||
|
||
private | ||
|
||
def autocorrect(corrector, node) | ||
corrector.replace(node.loc.name, node.loc.name.source.tr('C', 'A')) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters