mongoid/mongoid-slug

View on GitHub

Showing 4 of 4 total issues

Method uniqueness_scope has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

      def uniqueness_scope
        # If slug_scope is present, we need to handle whether it's a single scope or multiple scopes.
        if slug_scope
          # We'll track individual scope results in an array.
          scope_results = []
Severity: Minor
Found in lib/mongoid/slug/unique_slug.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 find_unique has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

      def find_unique(attempt = nil)
        MUTEX_FOR_SLUG.synchronize do
          @_slug = if attempt
                     attempt.to_url
                   else
Severity: Minor
Found in lib/mongoid/slug/unique_slug.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 slug has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def slug(*fields, &block)
        options = fields.extract_options!

        self.slug_scope            = options[:scope]
        self.slug_index            = options[:index].nil? ? true : options[:index]
Severity: Minor
Found in lib/mongoid/slug.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 build_index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def build_index(doc, scope_key = nil, by_model_type = false, locale = nil)
        # The order of field keys is intentional.
        # See: http://docs.mongodb.org/manual/core/index-compound/
        fields = {}
        fields[:_type] = 1 if by_model_type
Severity: Minor
Found in lib/mongoid/slug/index_builder.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

Severity
Category
Status
Source
Language