ruby-rdf/rdf

View on GitHub
lib/rdf/model/statement.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Statement has 33 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Statement
    include RDF::Resource

    ##
    # @private
Severity: Minor
Found in lib/rdf/model/statement.rb - About 4 hrs to fix

    Method initialize! has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize!
          @graph_name   = Node.intern(@graph_name)   if @graph_name.is_a?(Symbol)
          @subject   = if @subject.is_a?(Value)
            @subject.to_term
          elsif @subject.is_a?(Symbol)
    Severity: Minor
    Found in lib/rdf/model/statement.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 initialize! has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def initialize!
          @graph_name   = Node.intern(@graph_name)   if @graph_name.is_a?(Symbol)
          @subject   = if @subject.is_a?(Value)
            @subject.to_term
          elsif @subject.is_a?(Symbol)
    Severity: Minor
    Found in lib/rdf/model/statement.rb - About 1 hr to fix

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

          def dup
            options = Hash[@options]
            options[:subject] = subject.is_a?(RDF::Node) ? subject : subject.dup
            options[:predicate] = predicate.dup
            options[:object] = object.is_a?(RDF::Node) ? object : object.dup
      Severity: Minor
      Found in lib/rdf/model/statement.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 to_s has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_s
            (graph_name ? to_quad : to_triple).map do |term|
              if term.is_a?(Statement)
                "<<#{term.to_s[0..-3]}>>"
              elsif term.respond_to?(:to_base)
      Severity: Minor
      Found in lib/rdf/model/statement.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

      Avoid too many return statements within this method.
      Open

            return true
      Severity: Major
      Found in lib/rdf/model/statement.rb - About 30 mins to fix

        Method initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(subject = nil, predicate = nil, object = nil, options = {})
              if subject.is_a?(Hash)
                @options   = Hash[subject] # faster subject.dup
                @subject   = @options.delete(:subject)
                @predicate = @options.delete(:predicate)
        Severity: Minor
        Found in lib/rdf/model/statement.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