From 06eafbf85900d9e1f66bcd0648017dbf957ade11 Mon Sep 17 00:00:00 2001 From: Andy Brody Date: Wed, 5 Jul 2017 01:09:37 -0400 Subject: [PATCH 1/6] Update rubocop config to work again. --- .gitignore | 1 + .rubocop | 2 ++ .rubocop-disables.yml | 6 ++---- .rubocop.yml | 4 ++++ 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .rubocop diff --git a/.gitignore b/.gitignore index 0ce7bb3..1302abb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /pkg /rdoc /.yardoc +/tmp diff --git a/.rubocop b/.rubocop new file mode 100644 index 0000000..a87f108 --- /dev/null +++ b/.rubocop @@ -0,0 +1,2 @@ +--display-cop-names +--fail-level=W diff --git a/.rubocop-disables.yml b/.rubocop-disables.yml index ef15b6b..b85ed70 100644 --- a/.rubocop-disables.yml +++ b/.rubocop-disables.yml @@ -110,10 +110,8 @@ Style/ConstantName: Metrics/CyclomaticComplexity: Max: 22 -# Offense count: 1 -# Cop supports --auto-correct. -Style/DeprecatedHashMethods: - Enabled: false +Style/PreferredHashMethods: + EnforcedStyle: verbose # TODO: docs # Offense count: 17 diff --git a/.rubocop.yml b/.rubocop.yml index 4a11243..80d483d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,7 @@ --- inherit_from: - .rubocop-disables.yml + +AllCops: + Exclude: + - 'tmp/*.rb' From ee709b2fd8b84e9ae4dab0ea2bf033c69bf75a69 Mon Sep 17 00:00:00 2001 From: Andy Brody Date: Wed, 5 Jul 2017 01:09:48 -0400 Subject: [PATCH 2/6] Fix spurious rubocop warning around Exceptions. These exceptions already inherited from RestClient::Exception, but rubocop couldn't tell the difference between that and ::Exception. --- lib/restclient/exceptions.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/restclient/exceptions.rb b/lib/restclient/exceptions.rb index 5703bff..4d8bb77 100644 --- a/lib/restclient/exceptions.rb +++ b/lib/restclient/exceptions.rb @@ -148,7 +148,7 @@ module RestClient end # Compatibility - class ExceptionWithResponse < Exception + class ExceptionWithResponse < RestClient::Exception end # The request failed with an error code not managed by the code @@ -228,14 +228,14 @@ module RestClient # The server broke the connection prior to the request completing. Usually # this means it crashed, or sometimes that your network connection was # severed before it could complete. - class ServerBrokeConnection < Exception + class ServerBrokeConnection < RestClient::Exception def initialize(message = 'Server broke connection') super nil, nil self.message = message end end - class SSLCertificateNotVerified < Exception + class SSLCertificateNotVerified < RestClient::Exception def initialize(message = 'SSL certificate not verified') super nil, nil self.message = message From 98d6a7fab760c68ae8bc93f5ff712d5a090bd2c7 Mon Sep 17 00:00:00 2001 From: Andy Brody Date: Wed, 5 Jul 2017 01:45:37 -0400 Subject: [PATCH 3/6] Fix deprecated names of rubocop cops. --- .rubocop-disables.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.rubocop-disables.yml b/.rubocop-disables.yml index b85ed70..a9742d2 100644 --- a/.rubocop-disables.yml +++ b/.rubocop-disables.yml @@ -17,7 +17,7 @@ Lint/StringConversionInInterpolation: Lint/UnusedBlockArgument: Enabled: false -Lint/Eval: +Security/Eval: Exclude: - rest-client.windows.gemspec @@ -120,7 +120,7 @@ Style/Documentation: # Offense count: 9 # Configuration parameters: EnforcedStyle, SupportedStyles. -Style/DotPosition: +Layout/DotPosition: Enabled: false # Offense count: 1 @@ -134,24 +134,24 @@ Style/EachWithObject: # Offense count: 5 # Cop supports --auto-correct. -Style/EmptyLines: +Layout/EmptyLines: Enabled: false # Offense count: 11 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. -Style/EmptyLinesAroundClassBody: +Layout/EmptyLinesAroundClassBody: Enabled: false # Offense count: 1 # Cop supports --auto-correct. -Style/EmptyLinesAroundMethodBody: +Layout/EmptyLinesAroundMethodBody: Enabled: false # Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. -Style/EmptyLinesAroundModuleBody: +Layout/EmptyLinesAroundModuleBody: Enabled: false # Offense count: 31 @@ -186,7 +186,7 @@ Style/IfUnlessModifier: # Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. -Style/IndentHash: +Layout/IndentHash: Enabled: false # NOTABUG @@ -197,7 +197,7 @@ Style/Lambda: # TODO # Offense count: 14 # Cop supports --auto-correct. -Style/LeadingCommentSpace: +Layout/LeadingCommentSpace: Enabled: false # TODO @@ -296,47 +296,47 @@ Style/SignalException: # TODO # Offense count: 2 # Cop supports --auto-correct. -Style/SpaceAfterNot: +Layout/SpaceAfterNot: Enabled: false # Offense count: 19 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. -Style/SpaceAroundEqualsInParameterDefault: +Layout/SpaceAroundEqualsInParameterDefault: Enabled: false # Offense count: 20 # Cop supports --auto-correct. -Style/SpaceAroundOperators: +Layout/SpaceAroundOperators: Enabled: false # Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. -Style/SpaceBeforeBlockBraces: +Layout/SpaceBeforeBlockBraces: Enabled: false # Offense count: 37 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -Style/SpaceInsideBlockBraces: +Layout/SpaceInsideBlockBraces: Enabled: false # Offense count: 6 # Cop supports --auto-correct. -Style/SpaceInsideBrackets: +Layout/SpaceInsideBrackets: Enabled: false # Offense count: 181 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. -Style/SpaceInsideHashLiteralBraces: +Layout/SpaceInsideHashLiteralBraces: Enabled: false # TODO # Offense count: 9 # Cop supports --auto-correct. -Style/SpaceInsideParens: +Layout/SpaceInsideParens: Enabled: false # Offense count: 414 From 2ba8bdc8d5d93dc568c727a4c98294d28e76cbd8 Mon Sep 17 00:00:00 2001 From: Andy Brody Date: Wed, 5 Jul 2017 01:46:11 -0400 Subject: [PATCH 4/6] Enable LineLength cop. --- .rubocop-disables.yml | 7 +++---- Rakefile | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.rubocop-disables.yml b/.rubocop-disables.yml index a9742d2..9e3741a 100644 --- a/.rubocop-disables.yml +++ b/.rubocop-disables.yml @@ -200,11 +200,10 @@ Style/Lambda: Layout/LeadingCommentSpace: Enabled: false -# TODO -# Offense count: 218 -# Configuration parameters: AllowURI. Metrics/LineLength: - Max: 340 + Exclude: + - 'spec/**/*.rb' + - 'Rakefile' # TODO # Offense count: 28 diff --git a/Rakefile b/Rakefile index f804fdb..39b9873 100644 --- a/Rakefile +++ b/Rakefile @@ -70,8 +70,8 @@ namespace :all do task :build => ['ruby:build'] + \ WindowsPlatforms.map {|p| "windows:#{p}:build"} - desc "Create tag v#{RestClient::VERSION} and for all platforms build and push " \ - "rest-client #{RestClient::VERSION} to Rubygems" + desc "Create tag v#{RestClient::VERSION} and for all platforms build and " \ + "push rest-client #{RestClient::VERSION} to Rubygems" task :release => ['build', 'ruby:release'] + \ WindowsPlatforms.map {|p| "windows:#{p}:push"} From 28d60a0a9a1f4e821091786939d1d7747bcda8a8 Mon Sep 17 00:00:00 2001 From: Andy Brody Date: Wed, 5 Jul 2017 03:15:00 -0400 Subject: [PATCH 5/6] Run rubocop on Travis, add rake task. --- .rubocop-disables.yml | 3 +++ .travis.yml | 3 ++- Rakefile | 12 ++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.rubocop-disables.yml b/.rubocop-disables.yml index 9e3741a..5bd16e0 100644 --- a/.rubocop-disables.yml +++ b/.rubocop-disables.yml @@ -315,6 +315,9 @@ Layout/SpaceAroundOperators: Layout/SpaceBeforeBlockBraces: Enabled: false +Layout/EmptyLinesAroundBlockBody: + Enabled: false + # Offense count: 37 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. diff --git a/.travis.yml b/.travis.yml index 182000c..d5af272 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,8 @@ rvm: cache: bundler script: - bundle exec rake test + - bundle exec rake test + - bundle exec rake rubocop branches: except: diff --git a/Rakefile b/Rakefile index 39b9873..31d6bb0 100644 --- a/Rakefile +++ b/Rakefile @@ -38,12 +38,11 @@ desc 'Regenerate authors file' task :authors do Dir.chdir(File.dirname(__FILE__)) do File.open('AUTHORS', 'w') do |f| - f.write( <<-EOM + f.write <<-EOM The Ruby REST Client would not be what it is today without the help of the following kind souls: EOM - ) end sh 'git shortlog -s | cut -f 2 >> AUTHORS' @@ -130,3 +129,12 @@ Rake::RDocTask.new do |t| t.rdoc_files.include('README.md') t.rdoc_files.include('lib/*.rb') end + +############################ + +require 'rubocop/rake_task' + +RuboCop::RakeTask.new(:rubocop) do |t| + t.options = ['--display-cop-names'] +end +alias_task(:lint, :rubocop) From 03b6285a5b1dd208e0ebcf0314635fbe06ced6d5 Mon Sep 17 00:00:00 2001 From: Andy Brody Date: Wed, 5 Jul 2017 03:25:01 -0400 Subject: [PATCH 6/6] Rubocop ignore vendor/*. --- .rubocop-disables.yml | 3 +++ .rubocop.yml | 1 + 2 files changed, 4 insertions(+) diff --git a/.rubocop-disables.yml b/.rubocop-disables.yml index 5bd16e0..5c9bcb5 100644 --- a/.rubocop-disables.yml +++ b/.rubocop-disables.yml @@ -154,6 +154,9 @@ Layout/EmptyLinesAroundMethodBody: Layout/EmptyLinesAroundModuleBody: Enabled: false +Layout/EmptyLinesAroundExceptionHandlingKeywords: + Enabled: false + # Offense count: 31 # Configuration parameters: EnforcedStyle, SupportedStyles. Style/Encoding: diff --git a/.rubocop.yml b/.rubocop.yml index 80d483d..ec6c92b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,3 +5,4 @@ inherit_from: AllCops: Exclude: - 'tmp/*.rb' + - 'vendor/**/*'