ruby-rdf/rdf

View on GitHub
lib/rdf/query.rb

Summary

Maintainability
C
1 day
Test Coverage

Method execute has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def execute(queryable, bindings: {}, solutions: Solution.new, graph_name: nil, name: nil, **options, &block)
      # Use provided solutions to allow for query chaining
      # Otherwise, a quick empty solution simplifies the logic below; no special case for
      # the first pattern
      @solutions = Query::Solutions(solutions)
Severity: Minor
Found in lib/rdf/query.rb - About 4 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

Class Query has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Query
    include Enumerable
    autoload :Pattern,   'rdf/query/pattern'
    autoload :Solution,  'rdf/query/solution'
    autoload :Solutions, 'rdf/query/solutions'
Severity: Minor
Found in lib/rdf/query.rb - About 3 hrs to fix

    Method execute has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def execute(queryable, bindings: {}, solutions: Solution.new, graph_name: nil, name: nil, **options, &block)
          # Use provided solutions to allow for query chaining
          # Otherwise, a quick empty solution simplifies the logic below; no special case for
          # the first pattern
          @solutions = Query::Solutions(solutions)
    Severity: Major
    Found in lib/rdf/query.rb - About 2 hrs to fix

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

          def compile_hash_patterns(hash_patterns)
            patterns = []
            hash_patterns.each do |s, pos|
              raise ArgumentError, "invalid hash pattern: #{hash_patterns.inspect}" unless pos.is_a?(Hash)
              pos.each do |p, os|
      Severity: Minor
      Found in lib/rdf/query.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(*patterns, solutions: nil, graph_name: nil, name: nil, validate: false, **options, &block)
            @options = options.dup
            @solutions = Query::Solutions(solutions)
            graph_name = name if graph_name.nil?
            @graph_name = graph_name
      Severity: Minor
      Found in lib/rdf/query.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 apply_graph_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def apply_graph_name(graph_name = nil)
            graph_name ||= self.graph_name
            patterns.each {|pattern| pattern.graph_name = graph_name if pattern.graph_name.nil?} unless graph_name.nil?
          end
      Severity: Minor
      Found in lib/rdf/query.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