ruby-rdf/spira

View on GitHub

Showing 9 of 22 total issues

Class Base has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Base
    extend ActiveModel::Callbacks
    extend ActiveModel::Naming
    include ActiveModel::Conversion
    include ActiveModel::Dirty
Severity: Minor
Found in lib/spira/base.rb - About 4 hrs to fix

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

        def each
          if block_given?
            self.class.properties.each do |name, property|
              if value = read_attribute(name)
                if self.class.reflect_on_association(name)
    Severity: Minor
    Found in lib/spira/persistence.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 each has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

          def each(*args)
            raise Spira::NoTypeError, "Cannot count a #{self} without a reference type URI" unless type
    
            options = args.extract_options!
            conditions = options.delete(:conditions) || {}
    Severity: Minor
    Found in lib/spira/persistence.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

    File persistence.rb has 268 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Spira
      module Persistence
        extend ActiveSupport::Concern
    
        module ClassMethods
    Severity: Minor
    Found in lib/spira/persistence.rb - About 2 hrs to fix

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

            def id_for(identifier)
              case
                # Absolute URI's go through unchanged
              when identifier.is_a?(RDF::URI) && identifier.absolute?
                identifier
      Severity: Minor
      Found in lib/spira/persistence.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 qualified_const_get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def qualified_const_get(str)
            path = str.to_s.split('::')
            from_root = path[0].empty?
            if from_root
              from_root = []
      Severity: Minor
      Found in lib/spira/persistence.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 type has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def type(uri = nil)
            if uri
              if uri.is_a?(RDF::URI)
                ts = @types ? types : Set.new
                singleton_class.class_eval do
      Severity: Minor
      Found in lib/spira/resource.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 write_attribute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def write_attribute(name, value)
            name = name.to_s
            if self.class.properties[name]
              if @attrs[name].is_a?(Promise)
                changed_attributes[name] = @attrs[name] unless changed_attributes.include?(name)
      Severity: Minor
      Found in lib/spira/base.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 retrieve_attribute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def retrieve_attribute(name, options, sts)
            if self.class.reflections[name]
              sts.inject([]) do |values, statement|
                if statement.predicate == options[:predicate]
                  values << build_value(statement.object, options[:type])
      Severity: Minor
      Found in lib/spira/persistence.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