datamolecule/door_mat

View on GitHub

Showing 79 of 79 total issues

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

    def self.load_token(token, request, verbose=true)
      token = token.to_s.strip
      if DoorMat::Regex.session_guid.match(token).blank?
        DoorMat.configuration.logger.warn "WARN: #{request.remote_ip} Attempted to use token with invalid format #{token}" if verbose
        return nil
Severity: Minor
Found in app/models/door_mat/access_token.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 around_save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def around_save(record)
        return yield if DoorMat::Crypto.current_skip_crypto_callback.skip?

        clear_attribute = record.send("#{@attribute}")
        actor = record.send("#{@actor_column}")
Severity: Minor
Found in lib/door_mat/attr_asymmetric_store.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 with has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def self.with(address, password, request, cookies, controller)
Severity: Minor
Found in lib/door_mat/process/actor_sign_up.rb - About 35 mins to fix

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

          def self.add(email, actor, controller)
            return false unless email.valid?
    
            actor.with_lock do
              return false unless actor.can_add_email? email
    Severity: Minor
    Found in lib/door_mat/process/manage_email.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 with has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.with(address, password, request, cookies, controller)
            # Destroy any session linked to existing cookies before
            # replacing it by a new session
            DoorMat::Session.destroy_if_linked_to(cookies)
    
    
    Severity: Minor
    Found in lib/door_mat/process/actor_sign_up.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 set_primary has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.set_primary(encoded_address, actor)
            actor.with_lock do
              email = actor.email_from_urlsafe_encoded(encoded_address)
              return false if email.blank?
    
    
    Severity: Minor
    Found in lib/door_mat/process/manage_email.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

    Avoid parameter lists longer than 5 parameters. [7/5]
    Open

        def self.create_from_params(token_for, identifier, confirm_identifier, name, is_public, remember_me, request)
    Severity: Minor
    Found in app/models/door_mat/access_token.rb by rubocop

    This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.

    Avoid too many return statements within this method.
    Open

                return nil
    Severity: Major
    Found in app/models/door_mat/session.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return access_token
      Severity: Major
      Found in app/models/door_mat/access_token.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return false
        Severity: Major
        Found in lib/door_mat/process/reset_password.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return access_token
          Severity: Major
          Found in app/models/door_mat/access_token.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return nil
            Severity: Major
            Found in app/models/door_mat/session.rb - About 30 mins to fix

              Method owned_by has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def self.owned_by(owner)
                      password = DoorMat::Crypto::SymmetricStore.random_key
                      anonymous_actor = Actor.create_with(password)
                      return nil if anonymous_actor.blank?
              
              
              Severity: Minor
              Found in lib/door_mat/process/create_new_anonymous_actor.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

              Avoid parameter lists longer than 5 parameters. [6/5]
              Open

                    def self.with(email, password, is_public, remember_me, request, cookies)

              This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.

              Don't use IDs in selectors.
              Open

              #notice {
              Severity: Minor
              Found in app/assets/stylesheets/scaffold.css by csslint

              Avoid rescuing the Exception class. Perhaps you meant to rescue StandardError?
              Open

                    rescue Exception => e
                      DoorMat.configuration.logger.error "ERROR: CreateNewAnonymousActor failed to with error - #{e}"
                      nil

              This cop checks for rescue blocks targeting the Exception class.

              Example:

              # bad
              
              begin
                do_something
              rescue Exception
                handle_exception
              end

              Example:

              # good
              
              begin
                do_something
              rescue ArgumentError
                handle_exception
              end

              Rule doesn't have all its properties in alphabetical order.
              Open

              #error_explanation {
              Severity: Minor
              Found in app/assets/stylesheets/scaffold.css by csslint

              Non-local exit from iterator, without return value. next, break, Array#find, Array#any?, etc. is preferred.
              Open

                          return

              This cop checks for non-local exits from iterators without a return value. It registers an offense under these conditions:

              • No value is returned,
              • the block is preceded by a method chain,
              • the block has arguments,
              • the method which receives the block is not define_method or define_singleton_method,
              • the return is not contained in an inner scope, e.g. a lambda or a method definition.

              Example:

              class ItemApi
                rescue_from ValidationError do |e| # non-iteration block with arg
                  return { message: 'validation error' } unless e.errors # allowed
                  error_array = e.errors.map do |error| # block with method chain
                    return if error.suppress? # warned
                    return "#{error.param}: invalid" unless error.message # allowed
                    "#{error.param}: #{error.message}"
                  end
                  { message: 'validation error', errors: error_array }
                end
              
                def update_items
                  transaction do # block without arguments
                    return unless update_necessary? # allowed
                    find_each do |item| # block without method chain
                      return if item.stock == 0 # false-negative...
                      item.update!(foobar: true)
                    end
                  end
                end
              end

              Avoid rescuing the Exception class. Perhaps you meant to rescue StandardError?
              Open

                    rescue Exception => e
                      DoorMat.configuration.logger.error "ERROR: Failed to change actor password - #{e}"
                      raise e

              This cop checks for rescue blocks targeting the Exception class.

              Example:

              # bad
              
              begin
                do_something
              rescue Exception
                handle_exception
              end

              Example:

              # good
              
              begin
                do_something
              rescue ArgumentError
                handle_exception
              end

              Avoid rescuing the Exception class. Perhaps you meant to rescue StandardError?
              Open

                  rescue Exception => e
                    DoorMat.configuration.logger.error "ERROR: Failed to deliver reset password email for actor #{self.actor.id} to #{self.email.address} w #{parameters[:url]} - #{e}"
                    raise e

              This cop checks for rescue blocks targeting the Exception class.

              Example:

              # bad
              
              begin
                do_something
              rescue Exception
                handle_exception
              end

              Example:

              # good
              
              begin
                do_something
              rescue ArgumentError
                handle_exception
              end
              Severity
              Category
              Status
              Source
              Language