thekompanee/chamber

View on GitHub

Showing 22 of 22 total issues

Method call has 113 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def call
    key_pairs = namespaces.map do |namespace|
      Chamber::KeyPair.new(namespace:     namespace,
                           key_file_path: rootpath)
    end
Severity: Major
Found in lib/chamber/commands/initialize.rb - About 4 hrs to fix

    Method convert_environment_value has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      def convert_environment_value(environment_key, environment_value, settings_value) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
        return settings_value unless environment_value
        return                if %w{___nil___ ___null___}.include?(environment_value)
    
        case settings_value.class.name
    Severity: Minor
    Found in lib/chamber/filters/environment_filter.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 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def resolve
        options[:rootpath]   ||= Pathname.pwd
        options[:rootpath]     = Pathname.new(options[:rootpath])
        options[:namespaces] ||= []
        options[:preset]     ||= resolve_preset
    Severity: Minor
    Found in lib/chamber/context_resolver.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 execute has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def execute(raw_data = data) # rubocop:disable Metrics/CyclomaticComplexity
        securable_settings = super
        settings           = {}
    
        securable_settings.each_pair do |key, value|
    Severity: Minor
    Found in lib/chamber/filters/insecure_filter.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 decrypt has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.decrypt(_settings_key, value, decryption_keys) # rubocop:disable Metrics/AbcSize
        return value if decryption_keys.nil?
    
        key, iv, decoded_string = value
                                    .match(LARGE_DATA_STRING_PATTERN)
    Severity: Minor
    Found in lib/chamber/encryption_methods/ssl.rb - About 1 hr to fix

      Method convert_environment_value has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def convert_environment_value(environment_key, environment_value, settings_value) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
          return settings_value unless environment_value
          return                if %w{___nil___ ___null___}.include?(environment_value)
      
          case settings_value.class.name
      Severity: Minor
      Found in lib/chamber/filters/environment_filter.rb - About 1 hr to fix

        Method execute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def execute(raw_data = data)
            settings = {}
        
            raw_data.each_pair do |key, value|
              secure_value  = if value.respond_to? :each_pair
        Severity: Minor
        Found in lib/chamber/filters/secure_filter.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 decrypt has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def decrypt
            decrypted_settings = to_settings.decrypted.to_flattened_name_hash
            secure_settings    = to_settings.encrypted.to_flattened_name_hash
            file_contents      = read
        
        
        Severity: Minor
        Found in lib/chamber/file.rb - About 1 hr to fix

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

            def self.registered(app)
              app.configure do |inner_app|
                env  = inner_app.environment || ENV.fetch('RACK_ENV', nil)
                root = inner_app.root
          
          
          Severity: Minor
          Found in lib/chamber/integrations/sinatra.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 encryption_method has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def encryption_method(value)
              value_is_encrypted = value.is_a?(::String) &&
                                     (value.match(BASE64_STRING_PATTERN) ||
                                      value.match(LARGE_DATA_STRING_PATTERN))
          
          
          Severity: Minor
          Found in lib/chamber/filters/encryption_filter.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 deep_validate_keys has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.deep_validate_keys(object, &block)
              case object
              when ::Hash
                object.each do |(key, value)|
                  fail ::Chamber::Errors::NonConformingKey unless key == yield(key)
          Severity: Minor
          Found in lib/chamber/refinements/enumerable.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 decryption_method has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def decryption_method(value)
              if value.is_a?(::String)
                if value.match(BASE64_STRING_PATTERN)
                  EncryptionMethods::PublicKey
                elsif value.match(LARGE_DATA_STRING_PATTERN)
          Severity: Minor
          Found in lib/chamber/filters/decryption_filter.rb - About 25 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 deep_dup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def deep_dup
              dup.tap do |hash|
                each_pair do |key, value|
                  if key.frozen? && key.is_a?(::String)
                    hash[key] = value.deep_dup
          Severity: Minor
          Found in lib/chamber/refinements/deep_dup.rb - About 25 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_namespaces has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def resolve_namespaces(other)
              (other.respond_to?(:values) ? other.values : other)
                .map do |namespace|
                  namespace.respond_to?(:call) ? namespace.call : namespace
                end
          Severity: Minor
          Found in lib/chamber/context_resolver.rb - About 25 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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def resolve
              key_paths.each_with_object({}) do |path, memo|
                namespace = namespace_from_path(path) || '__default'
                value     = if path.readable?
                              path.read
          Severity: Minor
          Found in lib/chamber/keys/base.rb - About 25 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

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

              @signature_key = if keyish.is_a?(OpenSSL::PKey::RSA)
                                 keyish
                               elsif ::File.readable?(::File.expand_path(keyish))
                                 file_contents = ::File.read(::File.expand_path(keyish))
                                 OpenSSL::PKey::RSA.new(file_contents)
          Severity: Minor
          Found in lib/chamber/files/signature.rb and 1 other location - About 25 mins to fix
          lib/chamber/filters/encryption_filter.rb on lines 57..64

          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 30.

          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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def call
              disable_warnings do
                insecure_environment_variables.each_key do |key|
                  color = dry_run ? :blue : :green
          
          
          Severity: Minor
          Found in lib/chamber/commands/secure.rb - About 25 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

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

                memo[namespace] = if keyish.is_a?(OpenSSL::PKey::RSA)
                                    keyish
                                  elsif ::File.readable?(::File.expand_path(keyish))
                                    file_contents = ::File.read(::File.expand_path(keyish))
                                    OpenSSL::PKey::RSA.new(file_contents)
          Severity: Minor
          Found in lib/chamber/filters/encryption_filter.rb and 1 other location - About 25 mins to fix
          lib/chamber/files/signature.rb on lines 34..41

          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 30.

          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 decrypt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def decrypt
              decrypted_settings = to_settings.decrypted.to_flattened_name_hash
              secure_settings    = to_settings.encrypted.to_flattened_name_hash
              file_contents      = read
          
          
          Severity: Minor
          Found in lib/chamber/file.rb - About 25 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 deep_merge! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def deep_merge!(other_hash, &block)
              merge!(other_hash) do |key, this_val, other_val|
                if this_val.is_a?(::Hash) && other_val.is_a?(::Hash)
                  this_val.deep_merge(other_val, &block)
                elsif block
          Severity: Minor
          Found in lib/chamber/refinements/hash.rb - About 25 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