ruby-rdf/rdf

View on GitHub

Showing 188 of 213 total issues

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

    def merge!(other)
      @bindings.merge!(other.to_h) do |key, v1, v2|
        # Don't merge a pattern over a statement
        # This happens because JOIN does a reverse merge,
        # and a pattern is set in v2.
Severity: Minor
Found in lib/rdf/query/solution.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 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

Method insert_statements has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def insert_statements(statements)
      each = statements.respond_to?(:each_statement) ? :each_statement : :each
      statements.__send__(each) do |statement|
        if statement.embedded? && respond_to?(:supports?) && !supports?(:quoted_triples)
          raise ArgumentError, "Writable does not support quoted triples"
Severity: Minor
Found in lib/rdf/mixin/writable.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(repository, graph_name: nil, mutable: false, **options, &block)
      @repository = repository
      @snapshot = 
        repository.supports?(:snapshots) ? repository.snapshot : repository
      @options    = options.dup
Severity: Minor
Found in lib/rdf/transaction.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 find has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def find(uri)
        uri = RDF::URI(uri) if uri.is_a?(String)
        return nil unless uri.uri? && uri.valid?
        RDF::Vocabulary.detect do |v|
          if uri.length >= v.to_uri.length
Severity: Minor
Found in lib/rdf/vocabulary.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 ontology has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def ontology(*args)
        case args.length
        when 0
          @ontology if instance_variable_defined?(:@ontology)
        else
Severity: Minor
Found in lib/rdf/vocabulary.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(graph_name: nil, data: nil, **options, &block)
      @graph_name = case graph_name
        when nil then nil
        when RDF::Resource then graph_name
        else RDF::URI.new(graph_name)
Severity: Minor
Found in lib/rdf/model/graph.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

    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

      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

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

            def logger_common(*args, level:, **options)
              logger = self.logger(**options)
              # Some older code uses integer level numbers
              level = LOGGER_COMMON_LEVELS_REVERSE.fetch(level) if level.is_a?(Integer)
              logger.log_statistics[level] = logger.log_statistics[level].to_i + 1
        Severity: Minor
        Found in lib/rdf/util/logger.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

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

            def each_subject
              if block_given?
                values = {}
                each_statement do |statement|
                  value = statement.subject
        Severity: Minor
        Found in lib/rdf/mixin/enumerable.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

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

            def each_object # FIXME: deduplication
              if block_given?
                values = {}
                each_statement do |statement|
                  value = statement.object
        Severity: Minor
        Found in lib/rdf/mixin/enumerable.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

        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

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

            def -(other)
              new_dt = case other
              when YearMonthDuration
                @object << other.to_i
              when DayTimeDuration
        Severity: Minor
        Found in lib/rdf/model/literal/temporal.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

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

            def merge(other)
              other ||= RDF::Query::Solutions()
              return other if self.empty?
              return self if other.empty?
        
        
        Severity: Minor
        Found in lib/rdf/query/solutions.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

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

            def each_statement(&block)
              if block_given?
                begin
                  loop do
                    st = read_statement
        Severity: Minor
        Found in lib/rdf/reader.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

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

            def each_term
              if block_given?
                values = {}
                each_statement do |statement|
                  statement.terms.each do |value|
        Severity: Minor
        Found in lib/rdf/mixin/enumerable.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

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

            def each_predicate
              if block_given?
                values = {}
                each_statement do |statement|
                  value = statement.predicate
        Severity: Minor
        Found in lib/rdf/mixin/enumerable.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

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

            def ==(other)
              case other
              when Literal
                case
                when self.eql?(other)
        Severity: Minor
        Found in lib/rdf/model/literal.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

        Severity
        Category
        Status
        Source
        Language