Skip to content

Commit

Permalink
Rubocop refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
justin808 committed Nov 14, 2020
1 parent a8d69d8 commit c9b5df8
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 133 deletions.
136 changes: 15 additions & 121 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,32 @@ AllCops:
- '**/*.rake'

Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'node_modules/**/.*'
- 'node_modules/**/*'
<% `git status --ignored --porcelain`.lines.grep(/^!! /).each do |path| %>
- <%= path.sub(/^!! /, '') %>
<% end %>
- '**/*.js'
- '**/log/**/*'
- '**/node_modules/**/*'
- '**/public/**/*'
- '**/tmp/**/*'
- '.git/**/*'
- 'bin/**/*'
- 'coverage/**/*'
- 'db/**/*'
- 'db/schema.rb'
- 'db/seeds.rb'
- 'client/node_modules/**/*.*'
- 'client/node_modules/**/.*'
- 'bin/**/*'
- !ruby/regexp /old_and_unused\.rb$/
- 'spec/react_on_rails/dummy-for-generators/**/*'
- 'spec/dummy/Procfile.*'
- 'spec/dummy/bin/**/*'
- 'spec/dummy/node_modules/**/*'
- 'spec/dummy/node_modules/**/.*'
- 'gen-examples/examples/**/.*'
- 'gen-examples/examples/**/*'
- 'node_modules/**/*'
- 'spec/fixtures/**/*'
- 'spec/react_on_rails/dummy-for-generators/**/*'
- 'tmp/**/*'
- 'vendor/**/*'

Naming/FileName:
Exclude:
- 'Gemfile'
- 'spec/dummy/Gemfile'

# Turn off until we require 2.3 ruby
Style/SafeNavigation:
Enabled: false

Layout/LineLength:
Max: 120

Expand Down Expand Up @@ -98,106 +95,3 @@ Naming/RescuedExceptionsVariableName:
Style/GlobalVars:
Exclude:
- 'spec/dummy/config/environments/development.rb'

Style/FrozenStringLiteralComment:
EnforcedStyle: always

Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true

Layout/SpaceAroundMethodCallOperator:
Enabled: true

Lint/RaiseException:
Enabled: true

Lint/EmptyInterpolation:
Enabled: false

Lint/StructNewOverride:
Enabled: true

Style/ExponentialNotation:
Enabled: true

Style/SlicingWithRange:
Enabled: true

Layout/BeginEndAlignment: # (new in 0.91)
Enabled: true
Lint/BinaryOperatorWithIdenticalOperands: # (new in 0.89)
Enabled: true
Lint/ConstantDefinitionInBlock: # (new in 0.91)
Enabled: true
Lint/DeprecatedOpenSSLConstant: # (new in 0.84)
Enabled: true
Lint/DuplicateElsifCondition: # (new in 0.88)
Enabled: true
Lint/DuplicateRequire: # (new in 0.90)
Enabled: true
Lint/DuplicateRescueException: # (new in 0.89)
Enabled: true
Lint/EmptyConditionalBody: # (new in 0.89)
Enabled: true
Lint/EmptyFile: # (new in 0.90)
Enabled: true
Lint/FloatComparison: # (new in 0.89)
Enabled: true
Lint/IdentityComparison: # (new in 0.91)
Enabled: true
Lint/MissingSuper: # (new in 0.89)
Enabled: true
Lint/MixedRegexpCaptureTypes: # (new in 0.85)
Enabled: true
Lint/OutOfRangeRegexpRef: # (new in 0.89)
Enabled: true
Lint/SelfAssignment: # (new in 0.89)
Enabled: true
Lint/TopLevelReturnWithArgument: # (new in 0.89)
Enabled: true
Lint/TrailingCommaInAttributeDeclaration: # (new in 0.90)
Enabled: true
Lint/UnreachableLoop: # (new in 0.89)
Enabled: true
Lint/UselessMethodDefinition: # (new in 0.90)
Enabled: true
Lint/UselessTimes: # (new in 0.91)
Enabled: true
Style/AccessorGrouping: # (new in 0.87)
Enabled: true
Style/BisectedAttrAccessor: # (new in 0.87)
Enabled: true
Style/CaseLikeIf: # (new in 0.88)
Enabled: true
Style/CombinableLoops: # (new in 0.90)
Enabled: true
Style/ExplicitBlockArgument: # (new in 0.89)
Enabled: true
Style/GlobalStdStream: # (new in 0.89)
Enabled: true
Style/HashAsLastArrayItem: # (new in 0.88)
Enabled: true
Style/HashLikeCase: # (new in 0.88)
Enabled: true
Style/KeywordParametersOrder: # (new in 0.90)
Enabled: true
Style/OptionalBooleanParameter: # (new in 0.89)
Enabled: true
Style/RedundantAssignment: # (new in 0.87)
Enabled: true
Style/RedundantFetchBlock: # (new in 0.86)
Enabled: true
Style/RedundantFileExtensionInRequire: # (new in 0.88)
Enabled: true
Style/RedundantRegexpCharacterClass: # (new in 0.85)
Enabled: true
Style/RedundantRegexpEscape: # (new in 0.85)
Enabled: true
Style/RedundantSelfAssignment: # (new in 0.90)
Enabled: true
Style/SingleArgumentDig: # (new in 0.89)
Enabled: true
Style/SoleNestedConditional: # (new in 0.89)
Enabled: true
Style/StringConcatenation: # (new in 0.89)
Enabled: true
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ def exec_server_render_js(js_code, render_options, js_evaluator = nil)
console_script_lines = console_script.split("\n")
console_script_lines = console_script_lines[2..-2]
re = /console\.(?:log|error)\.apply\(console, \["\[SERVER\] (?<msg>.*)"\]\);/
if console_script_lines
console_script_lines.each do |line|
match = re.match(line)
Rails.logger.info { "[react_on_rails] #{match[:msg]}" } if match
end
console_script_lines&.each do |line|
match = re.match(line)
Rails.logger.info { "[react_on_rails] #{match[:msg]}" } if match
end
end
result
Expand Down
4 changes: 2 additions & 2 deletions rakelib/lint.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace :lint do

desc "Run Rubocop as shell"
task :rubocop do
sh_in_dir(gem_root, "bundle exec rubocop .")
sh_in_dir(gem_root, "bundle exec rubocop --version", "bundle exec rubocop .")
end

desc "Run scss-lint as shell"
Expand All @@ -17,7 +17,7 @@ namespace :lint do

desc "Run eslint as shell"
task :eslint do
sh_in_dir(gem_root, "yarn run eslint")
sh_in_dir(gem_root, "yarn run eslint --version", "yarn run eslint .")
end

desc "Run all eslint & rubocop linters. Skip scss"
Expand Down
5 changes: 2 additions & 3 deletions rakelib/task_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ def dummy_app_dir
end

# Executes a string or an array of strings in a shell in the given directory
def sh_in_dir(dir, shell_commands)
shell_commands = [shell_commands] if shell_commands.is_a?(String)
shell_commands.each { |shell_command| sh %(cd #{dir} && #{shell_command.strip}) }
def sh_in_dir(dir, *shell_commands)
shell_commands.flatten.each { |shell_command| sh %(cd #{dir} && #{shell_command.strip}) }
end

def bundle_install_in(dir)
Expand Down
15 changes: 15 additions & 0 deletions spec/dummy/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
inherit_from:
- ../../.rubocop.yml

AllCops:
Exclude:
- 'Procfile.*'
- 'bin/**/*'
- 'client/**/*'
- 'node_modules/react-on-rails'
- 'node_modules/**/*'
- 'public/webpack/**/*'

Metrics/BlockLength:
Exclude:
- 'config/routes.rb'
1 change: 0 additions & 1 deletion spec/dummy/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ source "https://rubygems.org"
eval_gemfile File.expand_path("../../Gemfile.development_dependencies", __dir__)

gem "react_on_rails", path: "../.."

2 changes: 1 addition & 1 deletion spec/.rubocop.yml → spec/dummy/spec/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ inherit_from:
- ../.rubocop.yml

Metrics/BlockLength:
Max: 180
Max: 200
5 changes: 5 additions & 0 deletions spec/react_on_rails/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
inherit_from:
- ../../.rubocop.yml

Metrics/BlockLength:
Max: 145

0 comments on commit c9b5df8

Please sign in to comment.