Showing 13 of 13 total issues

Method Ng has 160 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def Ng(group)
    case group
    when 1024
      @N = %w(
        EEAF0AB9 ADB38DD6 9C33F80A FA8FC5E8 60726187 75FF3C0B 9EA2314C
Severity: Major
Found in lib/sirp/parameters.rb - About 6 hrs to fix

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

        def get_challenge_and_proof(username, xverifier, xsalt, xaa)
          raise ArgumentError, 'username must be a string' unless username.is_a?(String) && !username.empty?
          raise ArgumentError, 'xverifier must be a string' unless xverifier.is_a?(String)
          raise ArgumentError, 'xverifier must be a hex string' unless xverifier =~ /^[a-fA-F0-9]+$/
          raise ArgumentError, 'xsalt must be a string' unless xsalt.is_a?(String)
    Severity: Minor
    Found in lib/sirp/verifier.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 process_challenge has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_challenge(username, password, xsalt, xbb)
          raise ArgumentError, 'username must be a string' unless username.is_a?(String) && !username.empty?
          raise ArgumentError, 'password must be a string' unless password.is_a?(String) && !password.empty?
          raise ArgumentError, 'xsalt must be a string' unless xsalt.is_a?(String)
          raise ArgumentError, 'xsalt must be a hex string' unless xsalt =~ /^[a-fA-F0-9]+$/
    Severity: Minor
    Found in lib/sirp/client.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 verify_session has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def verify_session(proof, client_M)
          raise ArgumentError, 'proof must be a hash' unless proof.is_a?(Hash)
          symbolize_keys_deep!(proof)
          raise ArgumentError, 'proof must have required hash keys' unless proof.keys == [:A, :B, :b, :I, :s, :v]
          raise ArgumentError, 'client_M must be a string' unless client_M.is_a?(String)
    Severity: Minor
    Found in lib/sirp/verifier.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 H has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def H(hash_klass, n, *a)
        nlen = 2 * ((('%x' % [n]).length * 4 + 7) >> 3)
    
        hashin = a.map do |s|
          next unless s
    Severity: Minor
    Found in lib/sirp/sirp.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 calc_client_S has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def calc_client_S(bb, a, k, x, u, n, g)
    Severity: Major
    Found in lib/sirp/sirp.rb - About 50 mins to fix

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

          def initialize(group = 2048)
            raise ArgumentError, 'must be an Integer' unless group.is_a?(Integer)
            raise ArgumentError, 'must be a known group size' unless [1024, 1536, 2048, 3072, 4096, 6144, 8192].include?(group)
      
            @N, @g, @hash = Ng(group)
      Severity: Minor
      Found in lib/sirp/verifier.rb and 1 other location - About 40 mins to fix
      lib/sirp/client.rb on lines 9..14

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

      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 2 locations. Consider refactoring.
      Open

          def initialize(group = 2048)
            raise ArgumentError, 'must be an Integer' unless group.is_a?(Integer)
            raise ArgumentError, 'must be a known group size' unless [1024, 1536, 2048, 3072, 4096, 6144, 8192].include?(group)
      
            @N, @g, @hash = Ng(group)
      Severity: Minor
      Found in lib/sirp/client.rb and 1 other location - About 40 mins to fix
      lib/sirp/verifier.rb on lines 9..14

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

      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 calc_server_S has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def calc_server_S(aa, b, v, u, n)
      Severity: Minor
      Found in lib/sirp/sirp.rb - About 35 mins to fix

        Method calc_B has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def calc_B(b, k, v, n, g)
        Severity: Minor
        Found in lib/sirp/sirp.rb - About 35 mins to fix

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

              def verify(server_HAMK)
                return false unless @H_AMK && server_HAMK
                return false unless server_HAMK.is_a?(String)
                return false unless server_HAMK =~ /^[a-fA-F0-9]+$/
          
          
          Severity: Minor
          Found in lib/sirp/client.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 generate_userauth has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def generate_userauth(username, password)
                raise ArgumentError, 'username must be a string' unless username.is_a?(String) && !username.empty?
                raise ArgumentError, 'password must be a string' unless password.is_a?(String) && !password.empty?
          
                @salt ||= SecureRandom.hex(10)
          Severity: Minor
          Found in lib/sirp/verifier.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 symbolize_keys_deep! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def symbolize_keys_deep!(h)
                h.keys.each do |k|
                  ks = k.respond_to?(:to_sym) ? k.to_sym : k
                  h[ks] = h.delete k # Preserve order even when k == ks
                  symbolize_keys_deep! h[ks] if h[ks].kind_of? Hash
          Severity: Minor
          Found in lib/sirp/verifier.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