ruby-rdf/rdf

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

Summary

Maintainability
F
3 days
Test Coverage

Class List has 55 methods (exceeds 20 allowed). Consider refactoring.
Open

  class RDF::List
    include RDF::Enumerable
    include RDF::Value
    include Comparable

Severity: Major
Found in lib/rdf/model/list.rb - About 7 hrs to fix

    File list.rb has 347 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module RDF
      ##
      # An RDF list.
      #
      # @example Constructing a new list
    Severity: Minor
    Found in lib/rdf/model/list.rb - About 4 hrs to fix

      Method valid? has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          def valid?
            li = subject
            list_nodes = []
            while li != RDF.nil do
              return false if list_nodes.include?(li)
      Severity: Minor
      Found in lib/rdf/model/list.rb - About 3 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 initialize has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(subject: nil, graph: nil, values: nil, wrap_transaction: false, &block)
            @subject = subject || RDF.nil
            @graph   = graph   || RDF::Graph.new
            is_empty = @graph.query({subject: subject, predicate: RDF.first}).empty?
      
      
      Severity: Minor
      Found in lib/rdf/model/list.rb - About 3 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 []= has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def []=(*args)
            start, length = 0, 0
      
            ary = self.to_a
      
      
      Severity: Minor
      Found in lib/rdf/model/list.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 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def initialize(subject: nil, graph: nil, values: nil, wrap_transaction: false, &block)
            @subject = subject || RDF.nil
            @graph   = graph   || RDF::Graph.new
            is_empty = @graph.query({subject: subject, predicate: RDF.first}).empty?
      
      
      Severity: Minor
      Found in lib/rdf/model/list.rb - About 1 hr to fix

        Method valid? has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def valid?
              li = subject
              list_nodes = []
              while li != RDF.nil do
                return false if list_nodes.include?(li)
        Severity: Minor
        Found in lib/rdf/model/list.rb - About 1 hr to fix

          Method []= has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def []=(*args)
                start, length = 0, 0
          
                ary = self.to_a
          
          
          Severity: Minor
          Found in lib/rdf/model/list.rb - About 1 hr to fix

            Avoid too many return statements within this method.
            Open

                  return list_nodes.all? do |li|
                    refs = @graph.query({object: li}).count
                    case refs
                    when 0 then li == subject
                    when 1 then true
            Severity: Major
            Found in lib/rdf/model/list.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return false unless firsts == 1 && rests == 1
              Severity: Major
              Found in lib/rdf/model/list.rb - About 30 mins to fix

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

                    def each_subject
                      return enum_subject unless block_given?
                
                      subject = self.subject
                      yield subject
                Severity: Minor
                Found in lib/rdf/model/list.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