chrisjensen/hash_redactor

View on GitHub

Showing 5 of 5 total issues

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

      def redact(data, opts = {})
        options = @options.merge(opts)
        
          redact_hash = options[:redact]
          
Severity: Minor
Found in lib/hash_redactor/hash_redactor.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_value has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def decrypt_value(result, hash_key, options)
        data_key = 'encrypted_' + hash_key.to_s
        iv_key = 'encrypted_' + hash_key.to_s + '_iv'
        
        if hash_key.is_a? Symbol
Severity: Minor
Found in lib/hash_redactor/hash_redactor.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 redact has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def redact(data, opts = {})
        options = @options.merge(opts)
        
          redact_hash = options[:redact]
          
Severity: Minor
Found in lib/hash_redactor/hash_redactor.rb - About 1 hr to fix

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

          def encrypt(hash, hash_key, options)
            raise "No encryption key specified. Please pass :encryption_key in options to new or redact" unless options[:encryption_key]
          
            data_key = 'encrypted_' + hash_key.to_s
            iv_key = 'encrypted_' + hash_key.to_s + '_iv'
    Severity: Minor
    Found in lib/hash_redactor/hash_redactor.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 decrypt has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def decrypt(data, opts = {})
            options = @options.merge opts
    
              redact_hash = options[:redact]
    
    
    Severity: Minor
    Found in lib/hash_redactor/hash_redactor.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