Skip to content

Commit

Permalink
silence warnings
Browse files Browse the repository at this point in the history
initialize vars in initializers

subclass hashie mash to silence warnings

rubocop fixes

add changelog entry

Revert "use correct params class in declared"

This reverts commit 61f0c8e.

fix tests
  • Loading branch information
thogg4 committed May 12, 2017
1 parent c644607 commit 8bc30ad
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 22 deletions.
23 changes: 9 additions & 14 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-02-19 15:40:46 -0500 using RuboCop version 0.47.1.
# on 2017-05-12 09:35:16 -0600 using RuboCop version 0.47.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 43
# Offense count: 46
Metrics/AbcSize:
Max: 44

# Offense count: 265
# Offense count: 276
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 3104

# Offense count: 1
# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 4

# Offense count: 8
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 281
Max: 285

# Offense count: 26
# Offense count: 28
Metrics/CyclomaticComplexity:
Max: 14

# Offense count: 993
# Offense count: 1084
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 215

# Offense count: 56
# Offense count: 57
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 33

# Offense count: 9
# Offense count: 10
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 212

# Offense count: 16
# Offense count: 18
Metrics/PerceivedComplexity:
Max: 14

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#### Fixes

* [#1632](https://github.com/ruby-grape/grape/pull/1632): Silence warnings - [@thogg4](https://github.com/thogg4).
* [#1615](https://github.com/ruby-grape/grape/pull/1615): Fix default and type validator when values is a Hash with no value attribute - [@jlfaber](https://github.com/jlfaber).
* Your contribution here.

Expand Down
5 changes: 5 additions & 0 deletions lib/grape/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ def initialize(new_settings, options = {}, &block)
@lazy_initialized = nil
@block = nil

@status = nil
@file = nil
@body = nil
@proc = nil

return unless block_given?

@source = block
Expand Down
7 changes: 5 additions & 2 deletions lib/grape/extensions/hashie/mash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module Hashie
module Mash
module ParamBuilder
extend ::ActiveSupport::Concern

included do
namespace_inheritable(:build_params_with, Grape::Extensions::Hashie::Mash::ParamBuilder)
end
Expand All @@ -14,10 +13,14 @@ def params_builder
end

def build_params
params = ::Hashie::Mash.new(rack_params)
params = Mash.new(rack_params)
params.deep_merge!(grape_routing_args) if env[Grape::Env::GRAPE_ROUTING_ARGS]
params
end

class Mash < ::Hashie::Mash
disable_warnings
end
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/grape/validations/validators/values.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def initialize(attrs, options, required, scope, opts = {})
warn '[DEPRECATION] The values validator proc option is deprecated. ' \
'The lambda expression can now be assigned directly to values.' if @proc
else
@excepts = nil
@values = nil
@proc = nil
@values = options
end
super
Expand Down
12 changes: 6 additions & 6 deletions spec/grape/extensions/param_builders/hashie/mash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def app
end
end

it 'should be of type Hashie::Mash' do
it 'should be of type Grape::Extensions::Hashie::Mash::ParamBuilder::Mash' do
get '/'
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('Hashie::Mash')
expect(last_response.body).to eq('Grape::Extensions::Hashie::Mash::ParamBuilder::Mash')
end
end
end
Expand All @@ -39,10 +39,10 @@ def app
end
end

it 'should be Hashie::Mash' do
it 'should be Grape::Extensions::Hashie::Mash::ParamBuilder::Mash' do
get '/'
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('Hashie::Mash')
expect(last_response.body).to eq('Grape::Extensions::Hashie::Mash::ParamBuilder::Mash')
end
end

Expand All @@ -55,10 +55,10 @@ def app
end
end

it 'should be Hashie::Mash' do
it 'should be Grape::Extensions::Hashie::Mash::ParamBuilder::Mash' do
get '/foo'
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('Hashie::Mash')
expect(last_response.body).to eq('Grape::Extensions::Hashie::Mash::ParamBuilder::Mash')
end
end

Expand Down

0 comments on commit 8bc30ad

Please sign in to comment.