Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

silence #327

Merged
merged 5 commits into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
--color
--format documentation
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 1.9
DisplayCopNames: true
Exclude:
- .git/**/*
- spec/core/middleware/response/sanitize_response_spec.rb
- vendor/**/*

# Align ends correctly.
Lint/EndAlignment:
Expand Down Expand Up @@ -33,3 +35,6 @@ Style/MultilineMethodCallIndentation:
# Checks indentation of binary operations that span more than one line.
Style/MultilineOperationIndentation:
EnforcedStyle: indented

Metrics:
Enabled: false
33 changes: 0 additions & 33 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,39 +65,6 @@ Lint/Void:
Exclude:
- 'lib/zendesk_api/middleware/request/encode_json.rb'

# Offense count: 27
Metrics/AbcSize:
Max: 68

# Offense count: 3
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 309

# Offense count: 19
Metrics/CyclomaticComplexity:
Max: 12

# Offense count: 425
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# URISchemes: http, https
Metrics/LineLength:
Max: 158

# Offense count: 37
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 52

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 140

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

# Offense count: 1
# Cop supports --auto-correct.
Performance/RedundantBlockCall:
Expand Down
4 changes: 2 additions & 2 deletions lib/zendesk_api/association.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def module_defines_class?(mod, klass_as_string)
# * parent - Parent instance
# * path - Optional path instead of resource name
def initialize(options = {})
@options = Hashie::Mash.new(options)
@options = SilentMash.new(options)
end

# Generate a path to the resource.
Expand All @@ -48,7 +48,7 @@ def initialize(options = {})
# * with_parent - Include the parent path (false by default)
# * with_id - Include the instance id, if possible (true)
def generate_path(*args)
options = Hashie::Mash.new(:with_id => true)
options = SilentMash.new(:with_id => true)
if args.last.is_a?(Hash)
original_options = args.pop
options.merge!(original_options)
Expand Down
3 changes: 2 additions & 1 deletion lib/zendesk_api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require 'zendesk_api/configuration'
require 'zendesk_api/collection'
require 'zendesk_api/lru_cache'
require 'zendesk_api/silent_mash'
require 'zendesk_api/middleware/request/etag_cache'
require 'zendesk_api/middleware/request/retry'
require 'zendesk_api/middleware/request/upload'
Expand Down Expand Up @@ -63,7 +64,7 @@ def current_user(reload = false)
# @return [Hash] The attributes of the current account or nil
def current_account(reload = false)
return @current_account if @current_account && !reload
@current_account = Hashie::Mash.new(connection.get('account/resolve').body)
@current_account = SilentMash.new(connection.get('account/resolve').body)
end

# Returns the current locale
Expand Down
2 changes: 1 addition & 1 deletion lib/zendesk_api/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Collection
# @param [Hash] options Any additional options to be passed in.
def initialize(client, resource, options = {})
@client, @resource_class, @resource = client, resource, resource.resource_name
@options = Hashie::Mash.new(options)
@options = SilentMash.new(options)

set_association_from_options
join_special_params
Expand Down
4 changes: 2 additions & 2 deletions lib/zendesk_api/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -621,15 +621,15 @@ def apply!(ticket = nil)
end

response = @client.connection.get(path)
Hashie::Mash.new(response.body.fetch("result", {}))
SilentMash.new(response.body.fetch("result", {}))
end

# Returns the update to a ticket that happens when a macro will be applied.
# @param [Ticket] ticket Optional {Ticket} to apply this macro to
def apply(ticket = nil)
apply!(ticket)
rescue Faraday::Error::ClientError
Hashie::Mash.new
SilentMash.new
end
end

Expand Down
8 changes: 8 additions & 0 deletions lib/zendesk_api/silent_mash.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'hashie'

module ZendeskAPI
# @private
class SilentMash < Hashie::Mash
disable_warnings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would have been nice to check for method existence 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update your hashie ... but I guess should bump required version here and yank the previous release ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I found out that I needed to bump hashie but it came as a bit of a surprise!

end
end
4 changes: 2 additions & 2 deletions lib/zendesk_api/trackie.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'hashie'
require 'zendesk_api/track_changes'
require 'zendesk_api/silent_mash'

module ZendeskAPI
# @private
class Trackie < Hashie::Mash
class Trackie < SilentMash
include ZendeskAPI::TrackChanges

def size
Expand Down
2 changes: 1 addition & 1 deletion spec/core/middleware/request/retry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def runtime
end

it "should print to logger" do
expect(client.config.logger).to receive(:warn).at_least(:once)
expect(client.config.logger).to receive(:warn).exactly(4)
client.connection.get("blergh")
end

Expand Down
1 change: 1 addition & 0 deletions spec/core/middleware/request/upload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
end

it "should handle invalid types" do
expect(subject).to receive(:warn)
expect(subject.call(:body => { :file => :invalid })[:body]).to eq({})
end

Expand Down
2 changes: 2 additions & 0 deletions spec/core/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def options
config.url = "https://my.zendesk.com/api/v2"
end

config.logger = Logger.new("/dev/null")

config.retry = true
end

Expand Down