Skip to content

Commit f7f540c

Browse files
committed
Catch up with rubocop cop updates
- Exclude Style/OneClassPerFile in offending files. - When building ast_node_children in lib/rubycritic/analysers/helpers/ast_node.rb, use grep instead of select with a kind check (Style/SelectByKind) - When generating hash in RubyCritic::AnalysisSummary, use to_h directly (Style/ReduceToHash)
1 parent 72967e8 commit f7f540c

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

.rubocop.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ Style/Documentation:
7272
Style/HashSyntax:
7373
EnforcedShorthandSyntax: either
7474

75+
Style/OneClassPerFile:
76+
Exclude:
77+
- 'lib/rubycritic/analysers/helpers/ast_node.rb'
78+
- 'test/analysers_test_helper.rb'
79+
- 'test/fakefs_helper.rb'
80+
- 'test/test_helper.rb'
81+
7582
Style/OpenStructUse:
7683
Exclude:
7784
- 'test/lib/rubycritic/generators/turbulence_test.rb'

lib/rubycritic/analysers/helpers/ast_node.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ def recursive_children(&block)
2323
end
2424

2525
def module_names
26-
ast_node_children = children.select do |child|
27-
child.is_a?(Parser::AST::Node)
28-
end
26+
ast_node_children = children.grep(Parser::AST::Node)
2927

3028
children_modules = ast_node_children.flat_map(&:module_names)
3129

lib/rubycritic/analysis_summary.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ def initialize(analysed_modules)
1111
end
1212

1313
def generate
14-
%w[A B C D F].each_with_object({}) do |rating, summary|
15-
summary[rating] = generate_for(rating)
16-
end
14+
%w[A B C D F].to_h { |rating| [rating, generate_for(rating)] }
1715
end
1816

1917
private

0 commit comments

Comments
 (0)