Skip to content

Commit

Permalink
Resolve various Lint/Style/Layout violations (#1060)
Browse files Browse the repository at this point in the history
* style: resolve rubocop Bundler/DuplicatedGem violations

* style: resolve rubocop Layout/ExtraSpacing violations

* style: resolve rubocop Layout/SpaceAfterComma violations

* style: resolve rubocopLint/BinaryOperatorWithIdenticalOperands violations

* style: resolve rubocop Lint/EmptyFile violations

* style: resolve rubocop Lint/NonDeterministicRequireOrder violations

* style: resolve rubocop Lint/ShadowedException violations

* style: resolve rubocop Naming/MemoizedInstanceVariableName violations

* style: resolve rubocop Style/ConditionalAssignment violations

* style: resolve rubocop Style/ModuleFunction violations

* style: resolve rubocop Style/SymbolProc violations

* style: resolve rubocop Layout/EmptyLineAfterGuardClause violations

* style: resolve rubocop Lint/AmbiguousBlockAssociation violations
  • Loading branch information
waltjones authored Jul 8, 2021
1 parent b0cf1da commit a294430
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 24 deletions.
1 change: 0 additions & 1 deletion gemfiles/rails41.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,5 @@ gem 'rspec-command'
gem 'webmock', :require => false

gem 'aws-sdk-sqs'
gem 'resque'

gemspec :path => '../'
2 changes: 1 addition & 1 deletion lib/rollbar/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module Rollbar
module JSON # :nodoc:
extend self
module_function

attr_writer :options_module

Expand Down
16 changes: 7 additions & 9 deletions lib/rollbar/middleware/js.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,13 @@ def js_snippet
end

def script_tag(content, env)
if (nonce = rails5_nonce(env))
script_tag_content = "\n<script type=\"text/javascript\" " \
"nonce=\"#{nonce}\">#{content}</script>"
elsif (nonce = secure_headers_nonce(env))
script_tag_content = "\n<script type=\"text/javascript\" " \
"nonce=\"#{nonce}\">#{content}</script>"
else
script_tag_content = "\n<script type=\"text/javascript\">#{content}</script>"
end
nonce = rails5_nonce(env) || secure_headers_nonce(env)
script_tag_content = if nonce
"\n<script type=\"text/javascript\" " \
"nonce=\"#{nonce}\">#{content}</script>"
else
"\n<script type=\"text/javascript\">#{content}</script>"
end

html_safe_if_needed(script_tag_content)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rollbar/plugins/delayed_job/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RollbarPlugin < ::Delayed::Plugin
if job.class.method_defined? :error
if job.error
::Rollbar.scope(:request => data)
.error(job.error,:use_exception_level_filters => true)
.error(job.error, :use_exception_level_filters => true)
end
elsif job.last_error
::Rollbar.scope(:request => data).error(
Expand Down
2 changes: 1 addition & 1 deletion lib/rollbar/plugins/rails/controller_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def rollbar_person_data
else
{}
end
rescue NoMethodError, NameError
rescue NameError
{}
end

Expand Down
1 change: 1 addition & 0 deletions lib/rollbar/truncation/remove_any_key_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def extract_title(body)
return extract_title_from_trace(body['trace']) if body['trace']

return unless body['trace_chain'] && body['trace_chain'][0]

extract_title_from_trace(body['trace_chain'][0])
end

Expand Down
1 change: 1 addition & 0 deletions lib/rollbar/truncation/remove_extra_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def delete_message_extra(body)

def delete_trace_chain_extra(body)
return unless body['trace_chain'] && body['trace_chain'][0]['extra']

body['trace_chain'][0].delete('extra')
end

Expand Down
2 changes: 1 addition & 1 deletion spec/delayed/backend/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def initialize(hash = {})
end

def self.all
@jobs ||= []
@all ||= []
end

def self.count
Expand Down
2 changes: 2 additions & 0 deletions spec/delayed/serialization/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# The tests at spec/rollbar/plugins/delayed_job_spec.rb
# expect to find a file here.
12 changes: 8 additions & 4 deletions spec/generators/rollbar/rollbar_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@
end

it 'outputs a help message and generates Rollbar initializer with ENV' do
expect(destination_root).to have_structure {
structure = proc do
directory 'config' do
directory 'initializers' do
file 'rollbar.rb' do
contains "config.access_token = ENV\['ROLLBAR_ACCESS_TOKEN'\]"
end
end
end
}
end

expect(destination_root).to have_structure(&structure)
end
end

Expand All @@ -38,7 +40,7 @@
end

it 'generates a Rollbar initializer with access token' do
expect(destination_root).to have_structure {
structure = proc do
directory 'config' do
directory 'initializers' do
file 'rollbar.rb' do
Expand All @@ -47,7 +49,9 @@
end
end
end
}
end

expect(destination_root).to have_structure(&structure)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/home_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
expect { get '/current_user' }.to raise_exception(NoMethodError)

body = Rollbar.last_report[:body]
trace = body[:trace] && body[:trace] || body[:trace_chain][0]
trace = body[:trace] || body[:trace_chain][0]

trace[:exception][:class].should eq('NoMethodError')
trace[:exception][:message].should =~ /^undefined method `-'/
Expand Down
2 changes: 1 addition & 1 deletion spec/rollbar/notifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
let(:payload) { { 'data' => { 'failsafe' => true } } }

it 'does not pass the message on' do
error_message = '[Rollbar] Error processing the item: ' \
error_message = '[Rollbar] Error processing the item: ' \
"SocketError, SocketError. Item: #{payload.inspect}"
expect(notifier)
.to receive(:log_error)
Expand Down
4 changes: 1 addition & 3 deletions spec/rollbar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1742,9 +1742,7 @@ def backtrace
# Reset state before Rollbar.configure
Rollbar::Delay::Thread.options = nil

Rollbar.configure do |config|
config.use_thread
end
Rollbar.configure(&:use_thread)

thread = Rollbar::Delay::Thread.call(payload)
sleep(1) # More reliable than Thread.pass to let the thread set its priority.
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
Rake::Task['dummy:db:test:prepare'].invoke
end

Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }

RSpec.configure do |config|
config.extend(Helpers)
Expand Down
1 change: 1 addition & 0 deletions spec/support/deploy_api/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def access_token?(request)

def access_token(request)
return if CGI.parse(request.env['QUERY_STRING'])['access_token'].empty?

CGI.parse(request.env['QUERY_STRING'])['access_token'][0]
end

Expand Down

0 comments on commit a294430

Please sign in to comment.