Skip to content

Commit

Permalink
Run Rubocop in Jenkins
Browse files Browse the repository at this point in the history
Also fix the rubocop issues that slipped in the meantime.
  • Loading branch information
iNecas committed Feb 6, 2019
1 parent 071f205 commit 9509894
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 21 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Lint/RescueException:
Metrics/ClassLength:
Exclude:
- 'test/**/*'

Metrics/BlockLength:
Exclude:
- 'test/**/*'

Naming/AccessorMethodName:
Enabled: false
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ group :test do
if RUBY_VERSION < '2.1'
gem 'public_suffix', '< 3'
gem 'rainbow', '< 3'
gem 'rubocop', '< 0.51.0'
else
gem 'public_suffix'
gem 'rubocop', '~> 0.52.1'
Expand Down
13 changes: 7 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'rake'
require 'rake/testtask'
require 'rubocop/rake_task' if RUBY_VERSION >= '2.1'

desc 'Default: run unit tests.'
task :default => :test
Expand All @@ -26,14 +27,14 @@ end

desc 'Test Dynflow plugin.'
task :test do
Rake::Task['rubocop'].invoke if defined? RuboCop
Rake::Task['test:core'].invoke
Rake::Task['test:api'].invoke
end

require 'rubocop/rake_task'

desc 'Run RuboCop on the lib directory'
RuboCop::RakeTask.new(:rubocop) do |task|
task.patterns = ['lib/**/*.rb', 'test/**/*.rb']
task.fail_on_error = false
if defined? RuboCop
desc 'Run RuboCop on the lib directory'
RuboCop::RakeTask.new(:rubocop) do |task|
task.fail_on_error = true
end
end
4 changes: 2 additions & 2 deletions lib/smart_proxy_dynflow_core/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def roll_log

class ProxyStructuredFormater < ::Dynflow::LoggerAdapters::Formatters::Abstract
def call(_severity, _datetime, _prog_name, message)
if ::Exception === message
if message.is_a?(::Exception)
subject = "#{message.message} (#{message.class})"
if @base.respond_to?(:exception)
@base.exception("Error details", message)
Expand All @@ -74,7 +74,7 @@ def format(message)
end

class ProxyAdapter < ::Dynflow::LoggerAdapters::Simple
def initialize(logger, level = Logger::DEBUG, formatters = [])
def initialize(logger, level = Logger::DEBUG, _formatters = [])
@logger = logger
@logger.level = level
@logger.formatter = ProxyStructuredFormater.new(@logger)
Expand Down
1 change: 0 additions & 1 deletion lib/smart_proxy_dynflow_core/task_launcher_registry.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module SmartProxyDynflowCore
class TaskLauncherRegistry
class << self

def register(name, launcher)
registry[name] = launcher
end
Expand Down
1 change: 0 additions & 1 deletion smart_proxy_dynflow_core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Gem::Specification.new do |gem|
gem.add_development_dependency('mocha', '~> 1')
gem.add_development_dependency('rack-test', '~> 0')
gem.add_development_dependency "rake", "~> 10.0"
gem.add_development_dependency('rubocop', '~> 0.52.1')
gem.add_development_dependency('webmock', '~> 1')

gem.add_runtime_dependency('dynflow', "~> 1.1")
Expand Down
14 changes: 7 additions & 7 deletions test/core_test/api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ def wait_until(iterations = 10, interval = 0.2)

describe 'POST /tasks/launch' do
it 'triggers a task by operation' do
klass = mock()
instance = mock()
klass = mock
instance = mock
klass.expects(:new).returns(instance)
instance.expects(:launch!).with({})
instance.expects(:results).returns({})
TaskLauncherRegistry.stubs(:registry).returns('something' => klass)
post '/tasks/launch', { :operation => 'something', :input => { } }.to_json, request_headers
post '/tasks/launch', { :operation => 'something', :input => {} }.to_json, request_headers
end

it 'fail 404 when operation is missing' do
Expand All @@ -133,13 +133,13 @@ def wait_until(iterations = 10, interval = 0.2)
describe 'GET /tasks/operations' do
it 'gets the list of operations' do
get '/tasks/operations', request_headers
response = JSON.load(last_response.body)
response = JSON.parse(last_response.body)
response.must_equal []

TaskLauncherRegistry.stubs(:registry).returns({'foo' => 'foo-v', 'bar' => 'bar-v', 'baz' => 'baz-v'})
TaskLauncherRegistry.stubs(:registry).returns({ 'foo' => 'foo-v', 'bar' => 'bar-v', 'baz' => 'baz-v' })
get '/tasks/operations', request_headers
response = JSON.load(last_response.body)
response.must_equal %w(foo bar baz)
response = JSON.parse(last_response.body)
response.must_equal %w[foo bar baz]
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions test/core_test/task_launcher_registry_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class TaskLauncherRegistryTest < MiniTest::Spec
end

it 'fetches the value' do
registry.expects(:registry).returns({'my_operation' => Integer})
registry.expects(:registry).returns({ 'my_operation' => Integer })
registry.fetch('my_operation').must_equal Integer
end
end

describe '#key' do
it 'checks presence of a key' do
registry.expects(:registry).returns({'my_operation' => Integer}).twice
registry.expects(:registry).returns({ 'my_operation' => Integer }).twice
assert registry.key?('my_operation')
refute registry.key?('missing')
end
Expand All @@ -45,7 +45,7 @@ class TaskLauncherRegistryTest < MiniTest::Spec
registry.register('foo', nil)
registry.register('bar', nil)
registry.register('baz', nil)
registry.operations.must_equal %w(foo bar baz)
registry.operations.must_equal %w[foo bar baz]
end
end
end
Expand Down

0 comments on commit 9509894

Please sign in to comment.