1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

Merge pull request #617 from rest-client/ab-rubocop

Fix up rubocop and add to Travis build
This commit is contained in:
Andy Brody 2017-07-05 04:03:17 -04:00 committed by GitHub
commit 1ee6d51000
7 changed files with 52 additions and 32 deletions

1
.gitignore vendored
View file

@ -6,3 +6,4 @@
/pkg /pkg
/rdoc /rdoc
/.yardoc /.yardoc
/tmp

2
.rubocop Normal file
View file

@ -0,0 +1,2 @@
--display-cop-names
--fail-level=W

View file

@ -17,7 +17,7 @@ Lint/StringConversionInInterpolation:
Lint/UnusedBlockArgument: Lint/UnusedBlockArgument:
Enabled: false Enabled: false
Lint/Eval: Security/Eval:
Exclude: Exclude:
- rest-client.windows.gemspec - rest-client.windows.gemspec
@ -110,10 +110,8 @@ Style/ConstantName:
Metrics/CyclomaticComplexity: Metrics/CyclomaticComplexity:
Max: 22 Max: 22
# Offense count: 1 Style/PreferredHashMethods:
# Cop supports --auto-correct. EnforcedStyle: verbose
Style/DeprecatedHashMethods:
Enabled: false
# TODO: docs # TODO: docs
# Offense count: 17 # Offense count: 17
@ -122,7 +120,7 @@ Style/Documentation:
# Offense count: 9 # Offense count: 9
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/DotPosition: Layout/DotPosition:
Enabled: false Enabled: false
# Offense count: 1 # Offense count: 1
@ -136,24 +134,27 @@ Style/EachWithObject:
# Offense count: 5 # Offense count: 5
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/EmptyLines: Layout/EmptyLines:
Enabled: false Enabled: false
# Offense count: 11 # Offense count: 11
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/EmptyLinesAroundClassBody: Layout/EmptyLinesAroundClassBody:
Enabled: false Enabled: false
# Offense count: 1 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/EmptyLinesAroundMethodBody: Layout/EmptyLinesAroundMethodBody:
Enabled: false Enabled: false
# Offense count: 9 # Offense count: 9
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/EmptyLinesAroundModuleBody: Layout/EmptyLinesAroundModuleBody:
Enabled: false
Layout/EmptyLinesAroundExceptionHandlingKeywords:
Enabled: false Enabled: false
# Offense count: 31 # Offense count: 31
@ -188,7 +189,7 @@ Style/IfUnlessModifier:
# Offense count: 6 # Offense count: 6
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/IndentHash: Layout/IndentHash:
Enabled: false Enabled: false
# NOTABUG # NOTABUG
@ -199,14 +200,13 @@ Style/Lambda:
# TODO # TODO
# Offense count: 14 # Offense count: 14
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/LeadingCommentSpace: Layout/LeadingCommentSpace:
Enabled: false Enabled: false
# TODO
# Offense count: 218
# Configuration parameters: AllowURI.
Metrics/LineLength: Metrics/LineLength:
Max: 340 Exclude:
- 'spec/**/*.rb'
- 'Rakefile'
# TODO # TODO
# Offense count: 28 # Offense count: 28
@ -298,47 +298,50 @@ Style/SignalException:
# TODO # TODO
# Offense count: 2 # Offense count: 2
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/SpaceAfterNot: Layout/SpaceAfterNot:
Enabled: false Enabled: false
# Offense count: 19 # Offense count: 19
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SpaceAroundEqualsInParameterDefault: Layout/SpaceAroundEqualsInParameterDefault:
Enabled: false Enabled: false
# Offense count: 20 # Offense count: 20
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/SpaceAroundOperators: Layout/SpaceAroundOperators:
Enabled: false Enabled: false
# Offense count: 9 # Offense count: 9
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SpaceBeforeBlockBraces: Layout/SpaceBeforeBlockBraces:
Enabled: false
Layout/EmptyLinesAroundBlockBody:
Enabled: false Enabled: false
# Offense count: 37 # Offense count: 37
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
Style/SpaceInsideBlockBraces: Layout/SpaceInsideBlockBraces:
Enabled: false Enabled: false
# Offense count: 6 # Offense count: 6
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/SpaceInsideBrackets: Layout/SpaceInsideBrackets:
Enabled: false Enabled: false
# Offense count: 181 # Offense count: 181
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
Style/SpaceInsideHashLiteralBraces: Layout/SpaceInsideHashLiteralBraces:
Enabled: false Enabled: false
# TODO # TODO
# Offense count: 9 # Offense count: 9
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/SpaceInsideParens: Layout/SpaceInsideParens:
Enabled: false Enabled: false
# Offense count: 414 # Offense count: 414

View file

@ -1,3 +1,8 @@
--- ---
inherit_from: inherit_from:
- .rubocop-disables.yml - .rubocop-disables.yml
AllCops:
Exclude:
- 'tmp/*.rb'
- 'vendor/**/*'

View file

@ -20,7 +20,8 @@ rvm:
cache: bundler cache: bundler
script: script:
bundle exec rake test - bundle exec rake test
- bundle exec rake rubocop
branches: branches:
except: except:

View file

@ -38,12 +38,11 @@ desc 'Regenerate authors file'
task :authors do task :authors do
Dir.chdir(File.dirname(__FILE__)) do Dir.chdir(File.dirname(__FILE__)) do
File.open('AUTHORS', 'w') do |f| 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 Ruby REST Client would not be what it is today without the help of
the following kind souls: the following kind souls:
EOM EOM
)
end end
sh 'git shortlog -s | cut -f 2 >> AUTHORS' sh 'git shortlog -s | cut -f 2 >> AUTHORS'
@ -70,8 +69,8 @@ namespace :all do
task :build => ['ruby:build'] + \ task :build => ['ruby:build'] + \
WindowsPlatforms.map {|p| "windows:#{p}:build"} WindowsPlatforms.map {|p| "windows:#{p}:build"}
desc "Create tag v#{RestClient::VERSION} and for all platforms build and push " \ desc "Create tag v#{RestClient::VERSION} and for all platforms build and " \
"rest-client #{RestClient::VERSION} to Rubygems" "push rest-client #{RestClient::VERSION} to Rubygems"
task :release => ['build', 'ruby:release'] + \ task :release => ['build', 'ruby:release'] + \
WindowsPlatforms.map {|p| "windows:#{p}:push"} WindowsPlatforms.map {|p| "windows:#{p}:push"}
@ -130,3 +129,12 @@ Rake::RDocTask.new do |t|
t.rdoc_files.include('README.md') t.rdoc_files.include('README.md')
t.rdoc_files.include('lib/*.rb') t.rdoc_files.include('lib/*.rb')
end end
############################
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop) do |t|
t.options = ['--display-cop-names']
end
alias_task(:lint, :rubocop)

View file

@ -148,7 +148,7 @@ module RestClient
end end
# Compatibility # Compatibility
class ExceptionWithResponse < Exception class ExceptionWithResponse < RestClient::Exception
end end
# The request failed with an error code not managed by the code # 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 # The server broke the connection prior to the request completing. Usually
# this means it crashed, or sometimes that your network connection was # this means it crashed, or sometimes that your network connection was
# severed before it could complete. # severed before it could complete.
class ServerBrokeConnection < Exception class ServerBrokeConnection < RestClient::Exception
def initialize(message = 'Server broke connection') def initialize(message = 'Server broke connection')
super nil, nil super nil, nil
self.message = message self.message = message
end end
end end
class SSLCertificateNotVerified < Exception class SSLCertificateNotVerified < RestClient::Exception
def initialize(message = 'SSL certificate not verified') def initialize(message = 'SSL certificate not verified')
super nil, nil super nil, nil
self.message = message self.message = message