grempe/secretsharing

View on GitHub

Showing 6 of 8 total issues

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

      def initialize(opts = {})
        opts = {
          :secret => get_random_number(32) # 32 Bytes, 256 Bits
        }.merge!(opts)

Severity: Minor
Found in lib/secretsharing/shamir/secret.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 miller_rabin_prime? has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def miller_rabin_prime?(n, g = 1000)
      return false if n == 1
      return true if n == 2

      d = n - 1
Severity: Minor
Found in lib/secretsharing/shamir.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 unpack_share has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def unpack_share(share)
        decoded  = Base64.urlsafe_decode64(share)
        h        = MultiJson.load(decoded, :symbolize_keys => true)

        @version         = h[:version].to_i                unless h[:version].nil?
Severity: Minor
Found in lib/secretsharing/shamir/share.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 initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(opts = {})
        opts = {
          :share           => nil,
          :version         => 1,
          :hmac            => nil,
Severity: Minor
Found in lib/secretsharing/shamir/share.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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(n, k = n)
        @n               = n.to_i
        @k               = k.to_i

        fail ArgumentError, 'n must be an Integer' unless @n.is_a?(Integer)
Severity: Minor
Found in lib/secretsharing/shamir/container.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 recover_secret has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def self.recover_secret(shares)
        return false unless shares.length >= shares[0].k

        # All Shares must have the same HMAC if derived from same Secret
        hmacs = shares.map(&:hmac).uniq
Severity: Minor
Found in lib/secretsharing/shamir/share.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