diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000000..d65f9ae0fe --- /dev/null +++ b/.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 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000000..7bbab17625 --- /dev/null +++ b/.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 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 625d44659d..fc1b706871 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/Gemfile b/Gemfile index a01c7005ac..51c7ad4933 100644 --- a/Gemfile +++ b/Gemfile @@ -12,3 +12,5 @@ gem "rack", "< 3.0" gem "minitest", "~> 5.9" gem "jruby-openssl", :platform => "jruby" + +gem "rubocop", "~> 0.49.1" diff --git a/Rakefile b/Rakefile index ec34c77744..bd51f19634 100644 --- a/Rakefile +++ b/Rakefile @@ -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 @@ -163,3 +167,5 @@ namespace :test do task :all => [:test, "test:integration"] end end + +task :default => [:rubocop, :test] diff --git a/examples/qc_config.rb b/examples/qc_config.rb index 26c3786e20..b67be07dde 100644 --- a/examples/qc_config.rb +++ b/examples/qc_config.rb @@ -6,7 +6,7 @@ CA[:domainname] = domainname CA[:CA_dir] = File.join Dir.pwd, "CA" CA[:password] = 'puma' - + CERTS << { :type => 'server', :hostname => 'puma' diff --git a/gemfiles/2.1-Gemfile b/gemfiles/2.1-Gemfile index a929221a98..67e3f1b2b7 100644 --- a/gemfiles/2.1-Gemfile +++ b/gemfiles/2.1-Gemfile @@ -10,3 +10,5 @@ gem "rack", "~> 1.6" gem "minitest", '~> 5.9' gem "jruby-openssl", :platform => "jruby" + +gem "rubocop", "~> 0.49.1" diff --git a/lib/puma/jruby_restart.rb b/lib/puma/jruby_restart.rb index f92a73ee37..da944e8ce7 100644 --- a/lib/puma/jruby_restart.rb +++ b/lib/puma/jruby_restart.rb @@ -80,4 +80,3 @@ def self.daemon_start(dir, argv) end end end - diff --git a/lib/puma/plugin/tmp_restart.rb b/lib/puma/plugin/tmp_restart.rb index c0fb87b845..7c2c402abd 100644 --- a/lib/puma/plugin/tmp_restart.rb +++ b/lib/puma/plugin/tmp_restart.rb @@ -32,4 +32,3 @@ def start(launcher) end end end - diff --git a/test/config/state_file_testing_config.rb b/test/config/state_file_testing_config.rb index 47f8bc1b1b..a920fb0dce 100644 --- a/test/config/state_file_testing_config.rb +++ b/test/config/state_file_testing_config.rb @@ -11,4 +11,3 @@ on_restart { 1 } after_worker_boot { 1 } lowlevel_error_handler { 1 } - diff --git a/test/shell/t1.rb b/test/shell/t1.rb index e0a529d7ee..ce2f3e0c8b 100644 --- a/test/shell/t1.rb +++ b/test/shell/t1.rb @@ -16,4 +16,3 @@ else exit 1 end - diff --git a/test/shell/t3.rb b/test/shell/t3.rb index cb52428aa6..2d48bca3f0 100644 --- a/test/shell/t3.rb +++ b/test/shell/t3.rb @@ -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" @@ -22,4 +22,3 @@ else exit 1 end - diff --git a/test/test_rack_handler.rb b/test/test_rack_handler.rb index 4859b5014f..79a790cc7e 100644 --- a/test/test_rack_handler.rb +++ b/test/test_rack_handler.rb @@ -179,4 +179,3 @@ def test_user_port_wins_over_config end end end - diff --git a/tools/trickletest.rb b/tools/trickletest.rb index e19ed718b5..11da57a640 100644 --- a/tools/trickletest.rb +++ b/tools/trickletest.rb @@ -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"