44uk/nis-ruby

View on GitHub

Showing 9 of 31 total issues

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

    def self.build(props)
      attrs = props.inject({}) do |hash, prop|
        hash[prop[:name]] = case prop[:name]
                            when 'divisibility'  then prop[:value].to_i
                            when 'initialSupply' then prop[:value].to_i
Severity: Minor
Found in lib/nis/struct/mosaic_properties.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 parse_options has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_options(options = {})
    defaults = DEFAULTS.dup
    options  = options.dup

    defaults[:url] = defaults[:url].call if defaults[:url].respond_to?(:call)
Severity: Minor
Found in lib/nis/client.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 parse_options has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def parse_options(options = {})
    defaults = DEFAULTS.dup
    options  = options.dup

    defaults[:url] = defaults[:url].call if defaults[:url].respond_to?(:call)
Severity: Minor
Found in lib/nis/client.rb - About 1 hr to fix

    Method mosaics_fee has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def mosaics_fee
          FEE_FACTOR * @transaction.mosaics.inject(0) do |sum, mo_attachment|
            mo = mo_attachment.mosaic_definition
            quantity = mo_attachment.quantity
            tmp_fee = 0
    Severity: Minor
    Found in lib/nis/fee/transfer.rb - About 45 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 request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def request(method, path, params = {})
        log(method, path, params)
        if connection.remote? && local_only?(path)
          raise Nis::Error, "The request (#{method} #{path}) is only permitted to local NIS."
        end
    Severity: Minor
    Found in lib/nis/client.rb - About 45 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 to_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_hash
          entity = @transaction.clone
    
          entity.amount *= 1_000_000 if entity.respond_to?(:amount)
    
    
    Severity: Minor
    Found in lib/nis/request/prepare_announce.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 apostille has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def apostille
        if @network == :testnet
          if private?
            raise 'Not implemented private apostille.'
          else
    Severity: Minor
    Found in lib/nis/apostille.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 rental has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def rental
          if @network == :testnet
            if root?
              { fee: 100 * 1_000_000,
                sink: 'TAMESPACEWH4MKFMBCVFERDPOOP4FK7MTDJEYP35' }
    Severity: Minor
    Found in lib/nis/transaction/provision_namespace.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 to_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_hash
          entity = @transaction.clone
    
          entity.amount *= 1_000_000 if entity.respond_to?(:amount)
    
    
    Severity: Minor
    Found in lib/nis/request/announce.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