k1LoW / awsecrets

AWS credentials loader
MIT License
17 stars 9 forks source link

unrecognized cop Performance/StringReplacement #27

Open glasswalk3r opened 4 years ago

glasswalk3r commented 4 years ago

I tried to execute the specs within the project:

$ bundle install --path=.vendor
$ bundle exec rake spec

I'm guessing that since there is not specific version of Rubocop at awsecrets.gemspec I'm running into problems due version compatibility:

Awsecrets
  has a version number
  Configration
    load --profile option
    load --region option
    load secrets.yml
    load secrets_other.yml via AWS_SECRETS_PATH
    load secrets_with_session_token.yml
    load AWS_PROIFLE
    load AWS_DEFAULT_PROIFLE
    load AWS_REGION
    load AWS_DEFAULT_REGION
    load AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
    load AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
    AssumeRole
      load AWS_PROIFLE=assumed_no_session_name
      load secrets_with_role_arn.yml
      when passing --profile assumed
        should create the proper config
        should call Aws::AssumeRoleCredentials.new with the correct client
        should call Aws::AssumeRoleCredentials.new with the correct role_arn
        should call Aws::AssumeRoleCredentials.new with the correct role_session_name
        should call Aws::AssumeRoleCredentials.new with the correct external_id
      load AWS_PROFILE=assumed
        should create the proper config
        should call Aws::AssumeRoleCredentials.new with the correct client
        should call Aws::AssumeRoleCredentials.new with the correct role_arn
        should call Aws::AssumeRoleCredentials.new with the correct role_session_name
        should call Aws::AssumeRoleCredentials.new with the correct external_id

Awsecrets
  Disable load YAML
    secrets_path: false
  Disable load YAML
    disable_load_secrets: true

Awsecrets
  Precedence
    --profile option > AWS_PROFILE
    --profile option > AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
    --profile option > secrets.yml (No .aws/config)
    --profile option > secrets.yml
    --region option > AWS_REGION
    AWS_REGION > AWS_DEFAULT_REGION

Finished in 0.07102 seconds (files took 0.43988 seconds to load)
32 examples, 0 failures

Running RuboCop...
.rubocop.yml: Metrics/LineLength has the wrong namespace - should be Layout
.rubocop.yml: Style/MultilineOperationIndentation has the wrong namespace - should be Layout
.rubocop.yml: Style/PredicateName has the wrong namespace - should be Naming
Error: unrecognized cop Performance/StringReplacement found in .rubocop.yml
RuboCop failed!
glasswalk3r commented 4 years ago

TLDR: even after commenting the "problematic" parts (I also tried to include rubocop-performance as a dependency of awsecrets with spec.add_development_dependency 'rubocop-performance' at awsecrets.gemspec) it seems there are a lot more of broken things.

Did some more testing (with rubocop 0.79.0) and got this:

Running RuboCop...
.rubocop.yml: Metrics/LineLength has the wrong namespace - should be Layout
.rubocop.yml: Style/MultilineOperationIndentation has the wrong namespace - should be Layout
.rubocop.yml: Style/PredicateName has the wrong namespace - should be Naming
Error: RuboCop found unsupported Ruby version 2.2 in `TargetRubyVersion` parameter (in .rubocop.yml). 2.2-compatible analysis was dropped after version 0.69.
Supported versions: 2.3, 2.4, 2.5, 2.6, 2.7
RuboCop failed!

After commenting out this configuration at .rubocop.yml:

Metrics/PerceivedComplexity:
  Max: 15

# Performance/StringReplacement:
#   Enabled: false

Style/Alias:
  Enabled: false

Then went back to .travis.yaml, check the versions there, and updated again .rubocop.yml:

AllCops:
  TargetRubyVersion: 2.3.4

But...

Finished in 0.0704 seconds (files took 0.43912 seconds to load)
32 examples, 0 failures

Running RuboCop...
.rubocop.yml: Metrics/LineLength has the wrong namespace - should be Layout
.rubocop.yml: Style/MultilineOperationIndentation has the wrong namespace - should be Layout
.rubocop.yml: Style/PredicateName has the wrong namespace - should be Naming
Inspecting 11 files
CCCCCCCWWWC

Offenses:

Gemfile:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
source 'https://rubygems.org'
^
Rakefile:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
require 'bundler/gem_tasks'
^
awsecrets.gemspec:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
lib = File.expand_path('../lib', __FILE__)
^
awsecrets.gemspec:1:12: C: Style/ExpandPathArguments: Use expand_path('lib', __dir__) instead of expand_path('../lib', __FILE__).
lib = File.expand_path('../lib', __FILE__)
           ^^^^^^^^^^^
awsecrets.gemspec:27:3: C: Gemspec/OrderedDependencies: Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency octorelease should appear before rubocop.
  spec.add_development_dependency 'octorelease'
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bin/console:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
#!/usr/bin/env ruby
^
bin/testcommand:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
#!/usr/bin/env ruby
^
lib/awsecrets.rb:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
require_relative 'awsecrets/version'
^
lib/awsecrets.rb:40:5: C: Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
    return false unless @profile
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/awsecrets.rb:54:5: C: Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
    return unless @profile
    ^^^^^^^^^^^^^^^^^^^^^^
lib/awsecrets.rb:55:5: C: Naming/MemoizedInstanceVariableName: Memoized variable @region does not match method name load_options. Use @load_options instead.
    @region ||= AWSConfig[@profile]['region']
    ^^^^^^^
lib/awsecrets.rb:64:5: C: Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
    return unless ENV['AWS_ACCESS_KEY_ID'] && ENV['AWS_SECRET_ACCESS_KEY']
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/awsecrets.rb:65:24: C: Layout/SpaceAroundOperators: Operator ||= should be surrounded by a single space.
    @access_key_id     ||= ENV['AWS_ACCESS_KEY_ID']
                       ^^^
lib/awsecrets.rb:67:5: C: Naming/MemoizedInstanceVariableName: Memoized variable @session_token does not match method name load_env. Use @load_env instead.
    @session_token     ||= ENV['AWS_SESSION_TOKEN']
    ^^^^^^^^^^^^^^
lib/awsecrets.rb:71:5: C: Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
    return if @disable_load_secrets
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/awsecrets.rb:74:36: C: Style/SafeNavigation: Use safe navigation (&.) instead of checking if an object exists before calling the method.
    @region ||= creds['region'] if creds && creds.include?('region')
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/awsecrets.rb:76:5: C: Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
    return unless creds && ...
    ^^^^^^^^^^^^^^^^^^^^^^
lib/awsecrets.rb:76:19: C: Style/SafeNavigation: Use safe navigation (&.) instead of checking if an object exists before calling the method.
    return unless creds && ...
                  ^^^^^^^^
lib/awsecrets.rb:79:24: C: Layout/SpaceAroundOperators: Operator ||= should be surrounded by a single space.
    @access_key_id     ||= creds['aws_access_key_id']
                       ^^^
lib/awsecrets.rb:86:5: C: Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
    return unless @role_arn
    ^^^^^^^^^^^^^^^^^^^^^^^
lib/awsecrets.rb:88:5: C: Naming/MemoizedInstanceVariableName: Memoized variable @credentials does not match method name load_yaml. Use @load_yaml instead.
    @credentials ||= role_creds(
    ^^^^^^^^^^^^
lib/awsecrets/version.rb:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
module Awsecrets
^
spec/configration_spec.rb:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
require 'spec_helper'
^
spec/configration_spec.rb:3:1: W: Lint/MissingCopEnableDirective: Re-enable Metrics/BlockLength cop with # rubocop:enable after disabling it.
# rubocop:disable Metrics/BlockLength
^
spec/disable_secrets_spec.rb:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
require 'spec_helper'
^
spec/disable_secrets_spec.rb:3:1: W: Lint/MissingCopEnableDirective: Re-enable Metrics/BlockLength cop with # rubocop:enable after disabling it.
# rubocop:disable Metrics/BlockLength
^
spec/precedence_spec.rb:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
require 'spec_helper'
^
spec/precedence_spec.rb:3:1: W: Lint/MissingCopEnableDirective: Re-enable Metrics/BlockLength cop with # rubocop:enable after disabling it.
# rubocop:disable Metrics/BlockLength
^
spec/spec_helper.rb:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
^
spec/spec_helper.rb:1:25: C: Style/ExpandPathArguments: Use expand_path('../lib', __dir__) instead of expand_path('../../lib', __FILE__).
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
                        ^^^^^^^^^^^

11 files inspected, 30 offenses detected
RuboCop failed!
glasswalk3r commented 4 years ago

Created #28 to "fix" the issues.