diff --git a/.rubocop-disables.yml b/.rubocop-disables.yml index 12bd0d2..ef15b6b 100644 --- a/.rubocop-disables.yml +++ b/.rubocop-disables.yml @@ -21,6 +21,14 @@ Lint/Eval: Exclude: - rest-client.windows.gemspec +Lint/HandleExceptions: + Exclude: + - lib/restclient/utils.rb + +Lint/UselessAccessModifier: + Exclude: + - lib/restclient/windows/root_certs.rb + # Offense count: 4 # Cop supports --auto-correct. Style/Alias: @@ -35,7 +43,7 @@ Style/AndOr: # TODO # Offense count: 3 # Cop supports --auto-correct. -Style/Blocks: +Style/BlockDelimiters: Enabled: false # Offense count: 48 @@ -90,6 +98,9 @@ Style/CollectionMethods: Style/ColonMethodCall: Enabled: false +Style/ConditionalAssignment: + EnforcedStyle: assign_inside_condition + # Offense count: 2 Style/ConstantName: Enabled: false @@ -161,12 +172,11 @@ Style/FileName: Style/FormatString: Enabled: false -# TODO: configure -# Offense count: 514 +# TODO: enable # Cop supports --auto-correct. # Configuration parameters: SupportedStyles. Style/HashSyntax: - EnforcedStyle: hash_rockets + Enabled: false # NOTABUG # Offense count: 8 @@ -337,10 +347,9 @@ Style/SpaceInsideParens: Style/StringLiterals: Enabled: false -# NOTABUG -# Offense count: 14 -# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. -Style/TrailingComma: +Style/TrailingCommaInLiteral: + EnforcedStyleForMultiline: comma +Style/TrailingCommaInArguments: Enabled: false # TODO: configure diff --git a/lib/restclient.rb b/lib/restclient.rb index fbcc97d..bdb53f0 100644 --- a/lib/restclient.rb +++ b/lib/restclient.rb @@ -96,6 +96,7 @@ module RestClient def self.proxy @proxy ||= nil end + def self.proxy=(value) @proxy = value @proxy_set = true diff --git a/lib/restclient/abstract_response.rb b/lib/restclient/abstract_response.rb index 680330c..7cd5b82 100644 --- a/lib/restclient/abstract_response.rb +++ b/lib/restclient/abstract_response.rb @@ -152,7 +152,7 @@ module RestClient # def self.beautify_headers(headers) headers.inject({}) do |out, (key, value)| - key_sym = key.gsub(/-/, '_').downcase.to_sym + key_sym = key.tr('-', '_').downcase.to_sym # Handle Set-Cookie specially since it cannot be joined by comma. if key.downcase == 'set-cookie' diff --git a/lib/restclient/response.rb b/lib/restclient/response.rb index 0d2c5ff..1f0ba89 100644 --- a/lib/restclient/response.rb +++ b/lib/restclient/response.rb @@ -47,8 +47,6 @@ module RestClient result end - private - def self.fix_encoding(response) charset = RestClient::Utils.get_encoding_from_headers(response.headers) encoding = nil @@ -68,6 +66,8 @@ module RestClient response end + private + def body_truncated(length) b = body if b.length > length