ksylvest/formula

View on GitHub

Showing 16 of 16 total issues

Method block has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def block(method = nil, options = {}, &block)
      options[:error] ||= error(method) if method

      components = "".html_safe

Severity: Minor
Found in lib/formula.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 input has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def input(method, options = {})
      options[:as] ||= as(method)
      options[:input] ||= {}

      return hidden_field method, options[:input] if options[:as] == :hidden
Severity: Minor
Found in lib/formula.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 association has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def association(method, collection, value, text, options = {})
      options[:as] ||= :select
      options[:association] ||= {}

      klass = [::Formula.association_class, options[:as]]
Severity: Minor
Found in lib/formula.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 association has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def association(method, collection, value, text, options = {})
Severity: Minor
Found in lib/formula.rb - About 35 mins to fix

    Avoid too many return statements within this method.
    Open

          when :string    then return :string
    Severity: Major
    Found in lib/formula.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            when :decimal   then return :number
      Severity: Major
      Found in lib/formula.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              when :integer   then return :number
        Severity: Major
        Found in lib/formula.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                when :datetime  then return :datetime
          Severity: Major
          Found in lib/formula.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  when :text      then return :text
            Severity: Major
            Found in lib/formula.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    when :date      then return :date
              Severity: Major
              Found in lib/formula.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      when :time      then return :time
                Severity: Major
                Found in lib/formula.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                        return ::Formula.default_as
                  Severity: Major
                  Found in lib/formula.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return :file if file?(method)
                    Severity: Major
                    Found in lib/formula.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                            when :timestamp then return :datetime
                      Severity: Major
                      Found in lib/formula.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                              when :float     then return :number
                        Severity: Major
                        Found in lib/formula.rb - About 30 mins to fix

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

                              def type(method)
                                if @object.respond_to?(:has_attribute?) && @object.has_attribute?(method)
                                  column = @object.column_for_attribute(method) if @object.respond_to?(:column_for_attribute)
                                  return column.type if column
                                end
                          Severity: Minor
                          Found in lib/formula.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