Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Commit

Permalink
Fix codeclimate issues
Browse files Browse the repository at this point in the history
  • Loading branch information
binarylogic committed Aug 24, 2016
1 parent b67bc0f commit 4a5eee4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/timber/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def json_shell(&block)
self.class.json_shell(&block)
end

def inspect(*args)
def inspect(*_args)
"#<#{self.class.name}:#{object_id} ...>"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/timber/internal_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Formatter < ::Logger::Formatter
TAG = "[Timber]"

# This method is invoked when a log event occurs
def call(severity, timestamp, progname, msg)
def call(_severity, _timestamp, _progname, msg)
"#{TAG} #{String === msg ? msg : msg.inspect}\n"
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/timber/log_devices/heroku_logplex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Timber
module LogDevices
class HerokuLogplex < IO
def initialize(options = {})
def initialize(_options = {})
super(STDOUT)
if formatter.is_a?(IO::HybridFormatter)
formatter.extend HybridFormatter
Expand Down
4 changes: 2 additions & 2 deletions lib/timber/macros/compactor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def self.compact(hash)
new_hash = {}
hash.each do |k, v|
deep_v = v.is_a?(Hash) ? compact(v) : v
if !v.nil? && v != [] && v != {}
new_hash[k] = v
if !deep_v.nil? && deep_v != [] && deep_v != {}
new_hash[k] = deep_v
end
end
new_hash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module Probes
class ActiveSupportLogSubscriber < Probe
module ActionController
def self.process_action(_log_subscriber, event, &_block)
if context = CurrentContext.get(Contexts::HTTPResponses::ActionController)
context = CurrentContext.get(Contexts::HTTPResponses::ActionController)
if context
context.event = event
end
yield
Expand Down
19 changes: 19 additions & 0 deletions spec/timber/macros/compactor_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require "spec_helper"

describe Timber::Macros::Compactor do
describe ".compact" do
let(:hash) { {} }
subject { described_class.compact(hash) }
it { should eq({}) }

context "nested" do
let(:hash) { {:whatever => {:nested => nil}} }
it { should eq({}) }
end

context "nested with other values" do
let(:hash) { {:whatever => {:nested => nil, :with_val => 1}, :another => 1} }
it { should eq({:whatever => {:with_val => 1}, :another => 1}) }
end
end
end

0 comments on commit 4a5eee4

Please sign in to comment.