sozialhelden/rosemary

View on GitHub
lib/rosemary/element.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Class Element has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Element
    include ActiveModel::Validations
    include Comparable

    # Unique ID
Severity: Minor
Found in lib/rosemary/element.rb - About 2 hrs to fix

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

        def method_missing(method, *args)
          methodname = method.to_s
          if methodname.slice(-1, 1) == '='
            if args.size != 1
              raise ArgumentError.new("wrong number of arguments (#{args.size} for 1)")
    Severity: Minor
    Found in lib/rosemary/element.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 add_tags has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_tags(new_tags)
          case new_tags
          when Array # Called with an array
            # Call recursively for each entry
            new_tags.each do |tag_hash|
    Severity: Minor
    Found in lib/rosemary/element.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 _check_id has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _check_id(id)
            if id.kind_of?(Integer)
                return id
            elsif id.kind_of?(String)
                raise ArgumentError, "ID must be an integer" unless id =~ /^-?[0-9]+$/
    Severity: Minor
    Found in lib/rosemary/element.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

    There are no issues that match your filters.

    Category
    Status