inossidabile/heimdallr

View on GitHub
lib/heimdallr/proxy/record.rb

Summary

Maintainability
D
1 day
Test Coverage

Method method_missing has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    def method_missing(method, *args, &block)
      suffix = method.to_s[-1]
      if %w(? = !).include? suffix
        normalized_method = method[0..-2].to_sym
      else
Severity: Minor
Found in lib/heimdallr/proxy/record.rb - About 5 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

Class Record has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Proxy::Record
    # Create a record proxy.
    #
    # @param context  security context
    # @param object   proxified record
Severity: Minor
Found in lib/heimdallr/proxy/record.rb - About 2 hrs to fix

    Method method_missing has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def method_missing(method, *args, &block)
          suffix = method.to_s[-1]
          if %w(? = !).include? suffix
            normalized_method = method[0..-2].to_sym
          else
    Severity: Major
    Found in lib/heimdallr/proxy/record.rb - About 2 hrs to fix

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

          def check_attributes
            @record.errors.clear
      
            if @record.new_record?
              action = :create
      Severity: Minor
      Found in lib/heimdallr/proxy/record.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 check_attributes has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def check_attributes
            @record.errors.clear
      
            if @record.new_record?
              action = :create
      Severity: Minor
      Found in lib/heimdallr/proxy/record.rb - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                    if result.respond_to? :restrict
                      result.restrict(@context, @options)
                    else
                      result
                    end
        Severity: Major
        Found in lib/heimdallr/proxy/record.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    elsif @options[:implicit]
                      nil
                    else
                      raise Heimdallr::PermissionError, "Attempt to fetch non-whitelisted attribute #{method}"
          Severity: Major
          Found in lib/heimdallr/proxy/record.rb - About 45 mins to fix

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

                def check_save_options(options)
                  if options[:validate] == false
                    raise Heimdallr::InsecureOperationError,
                        "Saving while omitting validation would omit security validations too"
                  end
            Severity: Minor
            Found in lib/heimdallr/proxy/record.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