scalefactory/aws-assume-role

View on GitHub

Showing 24 of 24 total issues

Method assume_role_from_profile has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def assume_role_from_profile(cfg, profile, opts)
        logger.debug "Entering assume_role_from_profile with #{cfg}, #{profile}, #{opts}"
        prof_cfg = cfg[profile]
        return unless cfg && prof_cfg
        opts[:source_profile] ||= prof_cfg["source_profile"]
Severity: Minor
Found in lib/aws_assume_role/store/shared_config_with_keyring.rb - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method credentials_from_keyring has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def credentials_from_keyring(profile, opts)
        logger.debug "Entering credentials_from_keyring"
        return unless @parsed_config
        logger.debug "credentials_from_keyring: @parsed_config found"
        prof_cfg = @parsed_config[profile]
Severity: Minor
Found in lib/aws_assume_role/store/shared_config_with_keyring.rb - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method resolve_credentials has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def resolve_credentials(type, break_if_successful = false, explicit_default_profile = false)
        factories_to_try = Repository.factories[type]
        factories_to_try.each do |x|
            options = to_h
            options[:credentials] = credentials if credentials && credentials.set?
Severity: Minor
Found in lib/aws_assume_role/credentials/factories/default_chain_provider.rb - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Class SharedConfigWithKeyring has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class AwsAssumeRole::Store::SharedConfigWithKeyring < AwsAssumeRole::Vendored::Aws::SharedConfig
    include AwsAssumeRole::Store
    include AwsAssumeRole::Logging

    attr_reader :parsed_config
Severity: Minor
Found in lib/aws_assume_role/store/shared_config_with_keyring.rb - About 2 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    module AwsAssumeRole::Cli
        desc t "commands.console.desc"
        command :console do |c|
            c.flag [:p, "profile"], desc: t("options.profile_name")
            c.flag ["role-session-name"], desc: t("options.role_session_name")
    Severity: Major
    Found in lib/aws_assume_role/cli/commands/console.rb and 1 other location - About 2 hrs to fix
    lib/aws_assume_role/cli/commands/run.rb on lines 5..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 82.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    module AwsAssumeRole::Cli
        desc t "commands.run.desc"
        command :run do |c|
            c.flag [:p, "profile"], desc: t("options.profile_name")
            c.flag ["role-session-name"], desc: t("options.role_session_name")
    Severity: Major
    Found in lib/aws_assume_role/cli/commands/run.rb and 1 other location - About 2 hrs to fix
    lib/aws_assume_role/cli/commands/console.rb on lines 5..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 82.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method assume_role_from_profile has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

            def assume_role_from_profile(cfg, profile, opts)
                if cfg && prof_cfg = cfg[profile]
                    opts[:source_profile] ||= prof_cfg["source_profile"]
                    if opts[:source_profile]
                        opts[:credentials] = credentials(profile: opts[:source_profile])
    Severity: Minor
    Found in lib/aws_assume_role/vendored/aws/shared_config.rb - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method assume_role_from_profile has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def assume_role_from_profile(cfg, profile, opts)
            logger.debug "Entering assume_role_from_profile with #{cfg}, #{profile}, #{opts}"
            prof_cfg = cfg[profile]
            return unless cfg && prof_cfg
            opts[:source_profile] ||= prof_cfg["source_profile"]
    Severity: Minor
    Found in lib/aws_assume_role/store/shared_config_with_keyring.rb - About 1 hr to fix

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

          CommandSchema = proc do
              required(:profile).maybe
              optional(:region) { filled? > format?(REGION_REGEX) }
              optional(:serial_number) { filled? > format?(MFA_REGEX) }
              required(:role_arn).maybe
      Severity: Major
      Found in lib/aws_assume_role/cli/actions/console.rb and 2 other locations - About 1 hr to fix
      lib/aws_assume_role/cli/actions/run.rb on lines 10..18
      lib/aws_assume_role/cli/actions/test.rb on lines 9..17

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 57.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

          CommandSchema = proc do
              required(:profile).maybe
              optional(:region) { filled? > format?(REGION_REGEX) }
              optional(:serial_number) { filled? > format?(MFA_REGEX) }
              required(:role_arn).maybe
      Severity: Major
      Found in lib/aws_assume_role/cli/actions/run.rb and 2 other locations - About 1 hr to fix
      lib/aws_assume_role/cli/actions/console.rb on lines 18..26
      lib/aws_assume_role/cli/actions/test.rb on lines 9..17

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 57.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

          CommandSchema = proc do
              required(:profile).maybe
              optional(:region) { filled? > format?(REGION_REGEX) }
              optional(:serial_number) { filled? > format?(MFA_REGEX) }
              required(:role_arn).maybe
      Severity: Major
      Found in lib/aws_assume_role/cli/actions/test.rb and 2 other locations - About 1 hr to fix
      lib/aws_assume_role/cli/actions/console.rb on lines 18..26
      lib/aws_assume_role/cli/actions/run.rb on lines 10..18

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 57.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Method initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(options = {})
              client_opts = {}
              @assume_role_params = {}
              options.each_pair do |key, value|
                  if self.class.assume_role_options.include?(key)
      Severity: Minor
      Found in lib/aws_assume_role/credentials/providers/assume_role_credentials.rb - About 55 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method mfa_session has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def mfa_session(cfg, profile, opts)
              prof_cfg = cfg[profile]
              return unless cfg && prof_cfg
              opts[:serial_number] ||= opts[:mfa_serial] || prof_cfg["mfa_serial"]
              opts[:source_profile] ||= prof_cfg["source_profile"]
      Severity: Minor
      Found in lib/aws_assume_role/store/shared_config_with_keyring.rb - About 55 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method resolve_parameter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def resolve_parameter(param, cfg, prof_cfg)
              return unless prof_cfg && cfg
              return prof_cfg[param] if prof_cfg.key? param
              source_profile = prof_cfg["source_profile"]
              return unless source_profile
      Severity: Minor
      Found in lib/aws_assume_role/store/shared_config_with_keyring.rb - About 55 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method validate_profile_exists has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def validate_profile_exists(profile)
                  unless (@parsed_credentials && @parsed_credentials[profile]) ||
                         (@parsed_config && @parsed_config[profile])
                      msg = "Profile `#{profile}' not found in #{@credentials_path}"
                      msg << " or #{@config_path}" if @config_path
      Severity: Minor
      Found in lib/aws_assume_role/vendored/aws/shared_config.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(options = {})
              logger.debug "SharedKeyringCredentials initiated with #{options}"
              @path = options[:path]
              @path ||= AwsAssumeRole.shared_config.credentials_path
              @profile_name = options[:profile_name] ||= options[:profile]
      Severity: Minor
      Found in lib/aws_assume_role/credentials/providers/shared_keyring_credentials.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(options)
              logger.debug "AwsAssumeRole::Credentials::Factories::AssumeRole initiated with #{options}"
              return unless options[:profile] || options[:role_arn]
              if options[:profile]
                  logger.debug "AwsAssumeRole: #{options[:profile]} found. Trying with profile"
      Severity: Minor
      Found in lib/aws_assume_role/credentials/factories/assume_role.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method fresh has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def fresh(options = {})
              @configuration = nil
              @semaphore = nil
              @assume_role_shared_config = nil
              @profile_name = nil
      Severity: Minor
      Found in lib/aws_assume_role/store/shared_config_with_keyring.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method fresh has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def fresh(options = {})
                  @profile_name = nil
                  @credentials_path = nil
                  @config_path = nil
                  @parsed_credentials = {}
      Severity: Minor
      Found in lib/aws_assume_role/vendored/aws/shared_config.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method region has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def region(opts = {})
                  p = opts[:profile] || @profile_name
                  if @config_enabled
                      if @parsed_credentials
                          region = @parsed_credentials.fetch(p, {})["region"]
      Severity: Minor
      Found in lib/aws_assume_role/vendored/aws/shared_config.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Severity
      Category
      Status
      Source
      Language