zold-io/wts.zold.io

View on GitHub
objects/ops.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method pull has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def pull(id = @item.id)
    if @user.fake?
      @log.info("It is a fake user with wallet ID #{id}, won't PULL from the network")
      remove
      rsa = OpenSSL::PKey::RSA.new(2048)
Severity: Minor
Found in objects/ops.rb - About 1 hr to fix

    Method pay has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def pay(keygap, bnf, amount, details)
        raise WTS::UserError, 'E187: Payment amount can\'t be zero' if amount.zero?
        raise WTS::UserError, 'E188: Payment amount can\'t be negative' if amount.negative?
        raise "The user #{@user.login} is not registered yet" unless @item.exists?
        raise "The account #{@user.login} is not confirmed yet" unless @user.confirmed?
    Severity: Minor
    Found in objects/ops.rb - About 1 hr to fix

      Method pay has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def pay(keygap, bnf, amount, details)
          raise WTS::UserError, 'E187: Payment amount can\'t be zero' if amount.zero?
          raise WTS::UserError, 'E188: Payment amount can\'t be negative' if amount.negative?
          raise "The user #{@user.login} is not registered yet" unless @item.exists?
          raise "The account #{@user.login} is not confirmed yet" unless @user.confirmed?
      Severity: Minor
      Found in objects/ops.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 pay_taxes has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def pay_taxes(keygap)
          raise "The user #{@user.login} is not registered yet" unless @item.exists?
          raise "The account #{@user.login} is not confirmed yet" unless @user.confirmed?
          if @user.fake?
            @log.info('It is a fake user, won\'t pay taxes')
      Severity: Minor
      Found in objects/ops.rb - About 1 hr to fix

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

          def pay_taxes(keygap)
            raise "The user #{@user.login} is not registered yet" unless @item.exists?
            raise "The account #{@user.login} is not confirmed yet" unless @user.confirmed?
            if @user.fake?
              @log.info('It is a fake user, won\'t pay taxes')
        Severity: Minor
        Found in objects/ops.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def initialize(item, user, wallets, remotes, copies, log: Zold::Log::NULL, network: 'test')
        Severity: Minor
        Found in objects/ops.rb - About 35 mins to fix

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

            def push
              if @user.fake?
                @log.info('It is a fake user, won\'t PUSH to the network')
                return
              end
          Severity: Minor
          Found in objects/ops.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

          There are no issues that match your filters.

          Category
          Status