ruby-rdf/spira

View on GitHub

Showing 13 of 13 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 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 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 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        class Double
      
          include Spira::Type
      
          def self.unserialize(value)
      Severity: Minor
      Found in lib/spira/types/double.rb and 1 other location - About 20 mins to fix
      lib/spira/types/float.rb on lines 12..24

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 27.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        class Float
      
          include Spira::Type
      
          def self.unserialize(value)
      Severity: Minor
      Found in lib/spira/types/float.rb and 1 other location - About 20 mins to fix
      lib/spira/types/double.rb on lines 12..24

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 27.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        class Time
          include Spira::Type
      
          def self.unserialize(value)
            object = value.object.to_time
      Severity: Minor
      Found in lib/spira/types/time.rb and 1 other location - About 15 mins to fix
      lib/spira/types/gYear.rb on lines 12..23

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 25.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        class GYear
          include Spira::Type
      
          def self.unserialize(value)
            object = value.object.to_i
      Severity: Minor
      Found in lib/spira/types/gYear.rb and 1 other location - About 15 mins to fix
      lib/spira/types/time.rb on lines 12..23

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 25.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Severity
      Category
      Status
      Source
      Language