Skip to content

Commit

Permalink
Let's use Rubocop! (#1325)
Browse files Browse the repository at this point in the history
* Add limited rubocop config and TODO config

* Remove trailing whitespaces and blanklines

* Add rubocop rake task; upd travis.yml
  • Loading branch information
palkan authored and nateberkopec committed Jun 4, 2017
1 parent 4af4a00 commit 2cb2357
Show file tree
Hide file tree
Showing 14 changed files with 188 additions and 10 deletions.
88 changes: 88 additions & 0 deletions .rubocop.yml
@@ -0,0 +1,88 @@
AllCops:
DisabledByDefault: true
TargetRubyVersion: 1.9.3
DisplayCopNames: true
StyleGuideCopsOnly: false
Exclude:
- 'tmp/**/*'
- 'gemfiles/vendor/**/*'
- 'vendor/**/*'
- 'Rakefile'

Layout/SpaceAfterColon:
Enabled: true

Layout/SpaceAroundKeyword:
Enabled: true

Layout/SpaceBeforeFirstArg:
Enabled: true

Layout/SpaceInsideParens:
Enabled: true

Layout/Tab:
Enabled: true

Layout/TrailingBlankLines:
Enabled: true

Layout/TrailingWhitespace:
Enabled: true

Lint/Debugger:
Enabled: true

Style/MethodDefParentheses:
Enabled: true

Style/MethodName:
Enabled: true
EnforcedStyle: snake_case
Exclude:
- 'test/**/**'

Style/TrailingCommaInArguments:
Enabled: true

Style/VariableName:
Enabled: true

Performance/Count:
Enabled: true

Performance/Detect:
Enabled: true

Performance/EndWith:
Enabled: true

Performance/FlatMap:
Enabled: true

Performance/HashEachMethods:
Enabled: true

Performance/RangeInclude:
Enabled: true

Performance/RedundantMerge:
Enabled: true

Performance/RedundantSortBy:
Enabled: true

Performance/ReverseEach:
Enabled: true

Performance/Sample:
Enabled: true

Performance/Size:
Enabled: true

Performance/StartWith:
Enabled: true

Performance/TimesMap:
Enabled: true
86 changes: 86 additions & 0 deletions .rubocop_todo.yml
@@ -0,0 +1,86 @@
inherit_from: "./.rubocop.yml"

# 29 offenses
Layout/SpaceAroundOperators:
Enabled: true

# 21 offenses
Layout/SpaceInsideBlockBraces:
Enabled: true

# 16 offenses
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true
EnforcedStyle: no_space

# 15 offenses
Layout/SpaceBeforeBlockBraces:
Enabled: true

# 15 offenses
Layout/SpaceInsideHashLiteralBraces:
Enabled: true
EnforcedStyle: no_space

# 8 offenses
Layout/EmptyLines:
Enabled: true

# 4 offenses
Layout/EmptyLinesAroundClassBody:
Enabled: true
Exclude:
- 'test/**/*'

# 6 offenses
Layout/EmptyLinesAroundMethodBody:
Enabled: true

# 5 offenses
Layout/EmptyLinesAroundModuleBody:
Enabled: true

# 5 offenses
Layout/IndentationWidth:
Enabled: true

# 3 offenses
Layout/AccessModifierIndentation:
EnforcedStyle: indent

# 2 offenses
Style/WhileUntilModifier:
Enabled: true

# 1 offense
Style/TernaryParentheses:
Enabled: true

# >200 offenses for 80
# 58 offenses for 100
# 18 offenses for 120
Metrics/LineLength:
Max: 120
AllowHeredoc: true
AllowURI: true
URISchemes:
- http
- https
IgnoreCopDirectives: false
IgnoredPatterns: []

# 1 offense
Metrics/ParameterLists:
Max: 5

# 1 offense
Performance/RedundantMatch:
Enabled: true

# 1 offense
Performance/RedundantBlockCall:
Enabled: true

# 1 offense
Performance/StringReplacement:
Enabled: true
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -7,7 +7,7 @@ before_install:
# bundler installation needed for jruby-head
# https://github.com/travis-ci/travis-ci/issues/5861
- gem install bundler -v 1.11.2
script: "TESTOPTS=-v bundle exec rake test"
script: "TESTOPTS=-v bundle exec rake"
branches:
only: [master]
rvm:
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -12,3 +12,5 @@ gem "rack", "< 3.0"
gem "minitest", "~> 5.9"

gem "jruby-openssl", :platform => "jruby"

gem "rubocop", "~> 0.49.1"
6 changes: 6 additions & 0 deletions Rakefile
Expand Up @@ -2,6 +2,10 @@ require "bundler/setup"
require "hoe"
require "rake/extensiontask"
require "rake/javaextensiontask"
require "rubocop/rake_task"

# Add rubocop task
RuboCop::RakeTask.new

IS_JRUBY = defined?(RUBY_ENGINE) ? RUBY_ENGINE == "jruby" : false

Expand Down Expand Up @@ -163,3 +167,5 @@ namespace :test do
task :all => [:test, "test:integration"]
end
end

task :default => [:rubocop, :test]
2 changes: 1 addition & 1 deletion examples/qc_config.rb
Expand Up @@ -6,7 +6,7 @@
CA[:domainname] = domainname
CA[:CA_dir] = File.join Dir.pwd, "CA"
CA[:password] = 'puma'

CERTS << {
:type => 'server',
:hostname => 'puma'
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/2.1-Gemfile
Expand Up @@ -10,3 +10,5 @@ gem "rack", "~> 1.6"
gem "minitest", '~> 5.9'

gem "jruby-openssl", :platform => "jruby"

gem "rubocop", "~> 0.49.1"
1 change: 0 additions & 1 deletion lib/puma/jruby_restart.rb
Expand Up @@ -80,4 +80,3 @@ def self.daemon_start(dir, argv)
end
end
end

1 change: 0 additions & 1 deletion lib/puma/plugin/tmp_restart.rb
Expand Up @@ -32,4 +32,3 @@ def start(launcher)
end
end
end

1 change: 0 additions & 1 deletion test/config/state_file_testing_config.rb
Expand Up @@ -11,4 +11,3 @@
on_restart { 1 }
after_worker_boot { 1 }
lowlevel_error_handler { 1 }

1 change: 0 additions & 1 deletion test/shell/t1.rb
Expand Up @@ -16,4 +16,3 @@
else
exit 1
end

3 changes: 1 addition & 2 deletions test/shell/t3.rb
Expand Up @@ -9,7 +9,7 @@

worker_index_within_number_of_workers = !File.file?("t3-worker-3-pid")

system "kill `cat t3-pid`"
system "kill `cat t3-pid`"

File.unlink "t3-pid" if File.file? "t3-pid"
File.unlink "t3-worker-0-pid" if File.file? "t3-worker-0-pid"
Expand All @@ -22,4 +22,3 @@
else
exit 1
end

1 change: 0 additions & 1 deletion test/test_rack_handler.rb
Expand Up @@ -179,4 +179,3 @@ def test_user_port_wins_over_config
end
end
end

2 changes: 1 addition & 1 deletion tools/trickletest.rb
Expand Up @@ -31,7 +31,7 @@ def do_test(st, chunk)
puts "length: #{content.length}"

threads = []
ARGV[1].to_i.times do
ARGV[1].to_i.times do
t = Thread.new do
size = 100
puts ">>>> #{size} sized chunks"
Expand Down

0 comments on commit 2cb2357

Please sign in to comment.