Skip to content

Commit

Permalink
Revert "Autocorrect violations of Layout/AlignHash Cop"
Browse files Browse the repository at this point in the history
This reverts commit da8c541.
  • Loading branch information
stoivo committed May 13, 2019
1 parent bca03f9 commit cfaeeb7
Show file tree
Hide file tree
Showing 23 changed files with 272 additions and 257 deletions.
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/**/*.rb'

Layout/AlignHash:
EnforcedHashRocketStyle:
- key
- table
EnforcedColonStyle:
- key
- table

Lint/InterpolationCheck:
Exclude:
- 'spec/**/*.rb'
Expand Down
74 changes: 37 additions & 37 deletions lib/rubocop/ast/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,45 @@ module AST
# root_node = parser.parse(buffer)
class Builder < Parser::Builders::Default
NODE_MAP = {
and: AndNode,
alias: AliasNode,
args: ArgsNode,
array: ArrayNode,
block: BlockNode,
break: BreakNode,
case: CaseNode,
class: ClassNode,
def: DefNode,
defined?: DefinedNode,
defs: DefNode,
ensure: EnsureNode,
for: ForNode,
hash: HashNode,
if: IfNode,
irange: RangeNode,
erange: RangeNode,
kwsplat: KeywordSplatNode,
module: ModuleNode,
or: OrNode,
pair: PairNode,
regexp: RegexpNode,
resbody: ResbodyNode,
retry: RetryNode,
csend: SendNode,
send: SendNode,
str: StrNode,
dstr: StrNode,
xstr: StrNode,
sclass: SelfClassNode,
super: SuperNode,
zsuper: SuperNode,
sym: SymbolNode,
until: UntilNode,
and: AndNode,
alias: AliasNode,
args: ArgsNode,
array: ArrayNode,
block: BlockNode,
break: BreakNode,
case: CaseNode,
class: ClassNode,
def: DefNode,
defined?: DefinedNode,
defs: DefNode,
ensure: EnsureNode,
for: ForNode,
hash: HashNode,
if: IfNode,
irange: RangeNode,
erange: RangeNode,
kwsplat: KeywordSplatNode,
module: ModuleNode,
or: OrNode,
pair: PairNode,
regexp: RegexpNode,
resbody: ResbodyNode,
retry: RetryNode,
csend: SendNode,
send: SendNode,
str: StrNode,
dstr: StrNode,
xstr: StrNode,
sclass: SelfClassNode,
super: SuperNode,
zsuper: SuperNode,
sym: SymbolNode,
until: UntilNode,
until_post: UntilNode,
when: WhenNode,
while: WhileNode,
when: WhenNode,
while: WhileNode,
while_post: WhileNode,
yield: YieldNode
yield: YieldNode
}.freeze

# Generates {Node} from the given information.
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cached_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def serialize_offense(offense)
begin_pos: offense.location.begin_pos,
end_pos: offense.location.end_pos
},
message: message(offense),
message: message(offense),
cop_name: offense.cop_name,
status: :uncorrected
status: :uncorrected
}
end

Expand Down
12 changes: 6 additions & 6 deletions lib/rubocop/cop/layout/closing_parenthesis_indentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ def check_for_elements(node, elements)

add_offense(right_paren,
location: right_paren,
message: message(correct_column,
left_paren,
right_paren))
message: message(correct_column,
left_paren,
right_paren))
end

def check_for_no_elements(node)
Expand All @@ -137,9 +137,9 @@ def check_for_no_elements(node)
@column_delta = correct_column - right_paren.column
add_offense(right_paren,
location: right_paren,
message: message(correct_column,
left_paren,
right_paren))
message: message(correct_column,
left_paren,
right_paren))
end

def expected_column(left_paren, elements)
Expand Down
10 changes: 5 additions & 5 deletions lib/rubocop/cop/lint/ambiguous_operator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class AmbiguousOperator < Cop
include ParserDiagnostic

AMBIGUITIES = {
'+' => { actual: 'positive number', possible: 'addition' },
'-' => { actual: 'negative number', possible: 'subtraction' },
'*' => { actual: 'splat', possible: 'multiplication' },
'&' => { actual: 'block', possible: 'binary AND' },
'**' => { actual: 'keyword splat', possible: 'exponent' }
'+' => { actual: 'positive number', possible: 'addition' },
'-' => { actual: 'negative number', possible: 'subtraction' },
'*' => { actual: 'splat', possible: 'multiplication' },
'&' => { actual: 'block', possible: 'binary AND' },
'**' => { actual: 'keyword splat', possible: 'exponent' }
}.each do |key, hash|
hash[:operator] = key
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/configurable_naming.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module ConfigurableNaming

FORMATS = {
snake_case: /^@{0,2}[\da-z_]+[!?=]?$/,
camelCase: /^@{0,2}_?[a-z][\da-zA-Z]+[!?=]?$/
camelCase: /^@{0,2}_?[a-z][\da-zA-Z]+[!?=]?$/
}.freeze
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/mixin/configurable_numbering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module ConfigurableNumbering
include ConfigurableFormatting

FORMATS = {
snake_case: /(?:[a-z_]|_\d+)$/,
normalcase: /(?:_\D*|[A-Za-z]\d*)$/,
snake_case: /(?:[a-z_]|_\d+)$/,
normalcase: /(?:_\D*|[A-Za-z]\d*)$/,
non_integer: /[A-Za-z_]$/
}.freeze
end
Expand Down
26 changes: 13 additions & 13 deletions lib/rubocop/cop/rails/refute_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ class RefuteMethods < Cop
MSG = 'Prefer `%<assert_method>s` over `%<refute_method>s`.'

CORRECTIONS = {
refute: 'assert_not',
refute_empty: 'assert_not_empty',
refute_equal: 'assert_not_equal',
refute_in_delta: 'assert_not_in_delta',
refute_in_epsilon: 'assert_not_in_epsilon',
refute_includes: 'assert_not_includes',
refute: 'assert_not',
refute_empty: 'assert_not_empty',
refute_equal: 'assert_not_equal',
refute_in_delta: 'assert_not_in_delta',
refute_in_epsilon: 'assert_not_in_epsilon',
refute_includes: 'assert_not_includes',
refute_instance_of: 'assert_not_instance_of',
refute_kind_of: 'assert_not_kind_of',
refute_nil: 'assert_not_nil',
refute_operator: 'assert_not_operator',
refute_predicate: 'assert_not_predicate',
refute_respond_to: 'assert_not_respond_to',
refute_same: 'assert_not_same',
refute_match: 'assert_no_match'
refute_kind_of: 'assert_not_kind_of',
refute_nil: 'assert_not_nil',
refute_operator: 'assert_not_operator',
refute_predicate: 'assert_not_predicate',
refute_respond_to: 'assert_not_respond_to',
refute_same: 'assert_not_same',
refute_match: 'assert_no_match'
}.freeze

OFFENSIVE_METHODS = CORRECTIONS.keys.freeze
Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/cop/variable_force/scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class VariableForce
# A scope instance holds a scope node and variable entries.
class Scope
OUTER_SCOPE_CHILD_INDICES = {
defs: 0..0,
defs: 0..0,
module: 0..0,
class: 0..1,
class: 0..1,
sclass: 0..0,
block: 0..0
block: 0..0
}.freeze

attr_reader :node, :variables, :naked_top_level
Expand Down
26 changes: 13 additions & 13 deletions lib/rubocop/formatter/formatter_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ module Formatter
# which invoke same method of each formatters.
class FormatterSet < Array
BUILTIN_FORMATTERS_FOR_KEYS = {
'progress' => ProgressFormatter,
'simple' => SimpleTextFormatter,
'clang' => ClangStyleFormatter,
'fuubar' => FuubarStyleFormatter,
'emacs' => EmacsStyleFormatter,
'json' => JSONFormatter,
'html' => HTMLFormatter,
'files' => FileListFormatter,
'offenses' => OffenseCountFormatter,
'disabled' => DisabledLinesFormatter,
'worst' => WorstOffendersFormatter,
'tap' => TapFormatter,
'quiet' => QuietFormatter,
'progress' => ProgressFormatter,
'simple' => SimpleTextFormatter,
'clang' => ClangStyleFormatter,
'fuubar' => FuubarStyleFormatter,
'emacs' => EmacsStyleFormatter,
'json' => JSONFormatter,
'html' => HTMLFormatter,
'files' => FileListFormatter,
'offenses' => OffenseCountFormatter,
'disabled' => DisabledLinesFormatter,
'worst' => WorstOffendersFormatter,
'tap' => TapFormatter,
'quiet' => QuietFormatter,
'autogenconf' => AutoGenConfigFormatter
}.freeze

Expand Down
8 changes: 4 additions & 4 deletions lib/rubocop/formatter/html_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ class ERBContext
include TextUtil

SEVERITY_COLORS = {
refactor: Color.new(0xED, 0x9C, 0x28, 1.0),
refactor: Color.new(0xED, 0x9C, 0x28, 1.0),
convention: Color.new(0xED, 0x9C, 0x28, 1.0),
warning: Color.new(0x96, 0x28, 0xEF, 1.0),
error: Color.new(0xD2, 0x32, 0x2D, 1.0),
fatal: Color.new(0xD2, 0x32, 0x2D, 1.0)
warning: Color.new(0x96, 0x28, 0xEF, 1.0),
error: Color.new(0xD2, 0x32, 0x2D, 1.0),
fatal: Color.new(0xD2, 0x32, 0x2D, 1.0)
}.freeze

LOGO_IMAGE_PATH =
Expand Down
32 changes: 16 additions & 16 deletions lib/rubocop/formatter/json_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def initialize(output, options = {})
super
@output_hash = {
metadata: metadata_hash,
files: [],
summary: { offense_count: 0 }
files: [],
summary: { offense_count: 0 }
}
end

Expand All @@ -37,42 +37,42 @@ def finished(inspected_files)
def metadata_hash
{
rubocop_version: RuboCop::Version::STRING,
ruby_engine: RUBY_ENGINE,
ruby_version: RUBY_VERSION,
ruby_engine: RUBY_ENGINE,
ruby_version: RUBY_VERSION,
ruby_patchlevel: RUBY_PATCHLEVEL.to_s,
ruby_platform: RUBY_PLATFORM
ruby_platform: RUBY_PLATFORM
}
end

def hash_for_file(file, offenses)
{
path: smart_path(file),
path: smart_path(file),
offenses: offenses.map { |o| hash_for_offense(o) }
}
end

def hash_for_offense(offense)
{
severity: offense.severity.name,
message: offense.message,
cop_name: offense.cop_name,
severity: offense.severity.name,
message: offense.message,
cop_name: offense.cop_name,
corrected: offense.corrected?,
location: hash_for_location(offense)
location: hash_for_location(offense)
}
end

# TODO: Consider better solution for Offense#real_column.
def hash_for_location(offense)
{
start_line: offense.line,
start_line: offense.line,
start_column: offense.real_column,
last_line: offense.last_line,
last_column: offense.last_column,
length: offense.location.length,
last_line: offense.last_line,
last_column: offense.last_column,
length: offense.location.length,
# `line` and `column` exist for compatibility.
# Use `start_line` and `start_column` instead.
line: offense.line,
column: offense.real_column
line: offense.line,
column: offense.real_column
}
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/rubocop/formatter/simple_text_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class SimpleTextFormatter < BaseFormatter
include PathUtil

COLOR_FOR_SEVERITY = {
refactor: :yellow,
refactor: :yellow,
convention: :yellow,
warning: :magenta,
error: :red,
fatal: :red
warning: :magenta,
error: :red,
fatal: :red
}.freeze

def started(_target_files)
Expand Down

0 comments on commit cfaeeb7

Please sign in to comment.