nick-desteffen/mongoid-scribe

View on GitHub

Showing 4 of 4 total issues

Method field has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

        def field
          return nil if private_field?

          if @klass.fields[@name].type == Boolean
            form_field = @form.check_box(@name)
Severity: Minor
Found in lib/mongoid/scribe/builders/field.rb - About 2 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

Method field has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def field
          return nil if private_field?

          if @klass.fields[@name].type == Boolean
            form_field = @form.check_box(@name)
Severity: Minor
Found in lib/mongoid/scribe/builders/field.rb - About 1 hr to fix

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

            def values
              return @values if @values
              @polymorphic = false
              @values = @config.fetch(:values, nil)
              if @values.respond_to?(:call) && @values.arity == 1
    Severity: Minor
    Found in lib/mongoid/scribe/builders/field.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def initialize(form, klass, document, name, config)
    Severity: Minor
    Found in lib/mongoid/scribe/builders/field.rb - About 35 mins to fix
      Severity
      Category
      Status
      Source
      Language