diff --git a/.rubocop.yml b/.rubocop.yml index 4e7bf46..242e8f5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,11 +1,13 @@ inherit_from: .rubocop_todo.yml +require: + - rubocop-minitest + - rubocop-performance + - rubocop-rake + AllCops: TargetRubyVersion: 2.5 -Rails: - Enabled: false - # Don't enforce documentation Style/Documentation: Enabled: false @@ -35,7 +37,7 @@ Naming/FileName: Naming/HeredocDelimiterNaming: Enabled: false -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: Enabled: false Style/TrailingCommaInArguments: @@ -59,9 +61,6 @@ Style/ClassAndModuleChildren: Style/GuardClause: Enabled: false -Style/BracesAroundHashParameters: - Enabled: false - Style/SignalException: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index caa0d60..00b7310 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,14 +1,145 @@ # This configuration was generated by -# `rubocop --auto-gen-config` -# on 2020-10-20 13:40:01 +0200 using RuboCop version 0.52.1. +# `rubocop --auto-gen-config --no-offense-counts --no-auto-gen-timestamp` +# using RuboCop version 1.28.2. # 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: 33 -# Cop supports --auto-correct. +# This cop supports safe auto-correction (--auto-correct). +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'lib/smart_proxy_dynflow/callback.rb' + - 'lib/smart_proxy_dynflow/continuous_output.rb' + - 'lib/smart_proxy_dynflow/core.rb' + - 'lib/smart_proxy_dynflow/process_manager.rb' + - 'lib/smart_proxy_dynflow/runner/base.rb' + - 'lib/smart_proxy_dynflow/runner/command.rb' + - 'lib/smart_proxy_dynflow/runner/dispatcher.rb' + - 'lib/smart_proxy_dynflow/settings_loader.rb' + - 'test/test_helper.rb' + +# This cop supports safe auto-correction (--auto-correct). +Layout/EmptyLineAfterMagicComment: + Enabled: false + +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowAliasSyntax, AllowedMethods. +# AllowedMethods: alias_method, public, protected, private +Layout/EmptyLinesAroundAttributeAccessor: + Exclude: + - 'lib/smart_proxy_dynflow/runner/dispatcher.rb' + - 'lib/smart_proxy_dynflow/runner/update.rb' + - 'lib/smart_proxy_dynflow/task_launcher/abstract.rb' + +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'test/io_buffer_test.rb' + +Lint/MissingSuper: + Exclude: + - 'lib/smart_proxy_dynflow/log.rb' + - 'lib/smart_proxy_dynflow/runner/dispatcher.rb' + - 'lib/smart_proxy_dynflow/ticker.rb' + +# This cop supports safe auto-correction (--auto-correct). +Minitest/AssertEmpty: + Exclude: + - 'test/io_buffer_test.rb' + +# This cop supports safe auto-correction (--auto-correct). +Minitest/AssertEqual: + Exclude: + - 'test/helpers_test.rb' + +# Configuration parameters: EnforcedStyleForLeadingUnderscores. +# SupportedStylesForLeadingUnderscores: disallowed, required, optional +Naming/MemoizedInstanceVariableName: + Exclude: + - 'lib/smart_proxy_dynflow/core.rb' + - 'lib/smart_proxy_dynflow/otp_manager.rb' + +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to +Naming/MethodParameterName: + Exclude: + - 'lib/smart_proxy_dynflow/runner/process_manager_command.rb' + +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Exclude: + - 'lib/smart_proxy_dynflow/runner/dispatcher.rb' + +# This cop supports safe auto-correction (--auto-correct). +Style/ExpandPathArguments: + Exclude: + - 'smart_proxy_dynflow.gemspec' + +# This cop supports safe auto-correction (--auto-correct). +Style/ExplicitBlockArgument: + Exclude: + - 'lib/smart_proxy_dynflow/middleware/keep_current_request_id.rb' + +# This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle. -# SupportedStyles: when_needed, always, never +# SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: Enabled: false + +# This cop supports safe auto-correction (--auto-correct). +Style/GlobalStdStream: + Exclude: + - 'lib/smart_proxy_dynflow/runner/base.rb' + +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'lib/smart_proxy_dynflow/api.rb' + +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Exclude: + - 'lib/smart_proxy_dynflow/action/single_runner_batch.rb' + - 'lib/smart_proxy_dynflow/runner/base.rb' + - 'lib/smart_proxy_dynflow/runner/dispatcher.rb' + - 'lib/smart_proxy_dynflow/runner/update.rb' + +# This cop supports safe auto-correction (--auto-correct). +Style/RedundantAssignment: + Exclude: + - 'lib/smart_proxy_dynflow/core.rb' + +# This cop supports safe auto-correction (--auto-correct). +Style/RedundantFileExtensionInRequire: + Exclude: + - 'test/api_test.rb' + +# This cop supports safe auto-correction (--auto-correct). +Style/RedundantFreeze: + Exclude: + - 'lib/smart_proxy_dynflow/log.rb' + - 'lib/smart_proxy_dynflow/version.rb' + +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowModifier. +Style/SoleNestedConditional: + Exclude: + - 'lib/smart_proxy_dynflow/otp_manager.rb' + +# This cop supports unsafe auto-correction (--auto-correct-all). +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'test/helpers_test.rb' + +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 197 diff --git a/Gemfile b/Gemfile index 5fa4a5f..70b222c 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,13 @@ source 'https://rubygems.org' gemspec :name => 'smart_proxy_dynflow' +group :rubocop do + gem 'rubocop', '~> 1.28.0' + gem 'rubocop-minitest' + gem 'rubocop-performance' + gem 'rubocop-rake' +end + group :development do gem 'pry' end @@ -12,7 +19,6 @@ group :test do gem 'public_suffix' gem 'rack-test' gem 'rake' - gem 'rubocop', '~> 0.52.1' gem 'smart_proxy', :git => "https://github.com/theforeman/smart-proxy", :branch => "develop" gem 'webmock' end diff --git a/lib/smart_proxy_dynflow/io_buffer.rb b/lib/smart_proxy_dynflow/io_buffer.rb index 98cdbfe..675a3eb 100644 --- a/lib/smart_proxy_dynflow/io_buffer.rb +++ b/lib/smart_proxy_dynflow/io_buffer.rb @@ -71,7 +71,7 @@ def close def read_available! data = '' loop { data += @io.read_nonblock(4096) } - rescue IO::WaitReadable # rubocop:disable Lint/HandleExceptions + rescue IO::WaitReadable # rubocop:disable Lint/SuppressedException rescue EOFError close ensure @@ -88,7 +88,7 @@ def write_available! n = @io.write_nonblock(@buffer) @buffer = @buffer[n..-1] end - rescue IO::WaitWritable # rubocop:disable Lint/HandleExceptions + rescue IO::WaitWritable # rubocop:disable Lint/SuppressedException rescue EOFError close end