ruby-rdf/rdf

View on GitHub

Showing 213 of 213 total issues

Method new has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def self.new(value, language: nil, datatype: nil, direction: nil, lexical: nil, validate: false, canonicalize: false, **options)
      if language && direction
        raise ArgumentError, "datatype with language and direction must be rdf:dirLangString" if (datatype || RDF.dirLangString).to_s != RDF.dirLangString.to_s
      elsif language
        raise ArgumentError, "datatype with language must be rdf:langString" if (datatype || RDF.langString).to_s != RDF.langString.to_s
Severity: Minor
Found in lib/rdf/model/literal.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 logger has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def logger(logger: nil, **options)
      # Guard against undefined instance variables, which may be a warning if used.
      @options = {} unless instance_variable_defined?(:@options) || frozen?
      logger ||= @logger if instance_variable_defined?(:@logger)
      logger = @options[:logger] if logger.nil? && instance_variable_defined?(:@options) && @options
Severity: Minor
Found in lib/rdf/util/logger.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 property has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def property(*args)
        case args.length
        when 0
          Term.intern("#{self}property", vocab: self, attributes: {})
        else
Severity: Minor
Found in lib/rdf/vocabulary.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 serialize_value has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def serialize_value(value, key, indent: "")
        if value.is_a?(Hash)
          # Favor English
          keys = value.keys
          keys = keys.include?(:en) ? (keys - [:en]).sort.unshift(:en) : keys.sort
Severity: Minor
Found in lib/rdf/vocab/writer.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 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

    Consider simplifying this complex logical expression.
    Open

          if @options[:rdfstar] && match(ST_START)
            subject   = read_uriref || read_node || read_quotedTriple || fail_subject
            predicate = read_uriref(intern: true) || fail_predicate
            object    = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
            if !match(ST_END)
    Severity: Critical
    Found in lib/rdf/ntriples/reader.rb - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

                unless blank? || read_comment
                  subject   = read_uriref || read_node || read_quotedTriple || fail_subject
                  predicate = read_uriref(intern: true) || fail_predicate
                  object    = read_uriref || read_node || read_literal || read_quotedTriple || fail_object
      
      
      Severity: Critical
      Found in lib/rdf/ntriples/reader.rb - About 2 hrs to fix

        Method options has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.options(argv, format: nil)
              options = OptionParser.new
              cli_opts = OPTIONS.map(&:dup)
              logger = Logger.new($stderr)
              logger.level = Logger::WARN
        Severity: Minor
        Found in lib/rdf/cli.rb - About 1 hr to fix

          Method / has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def /(fragment)
                frag = fragment.respond_to?(:to_uri) ? fragment.to_uri : RDF::URI(fragment.to_s)
                raise ArgumentError, "Non-absolute URI or string required, got #{frag}" unless frag.relative?
                if urn?
                  RDF::URI.intern(to_s.sub(/:+$/,'') + ':' + fragment.to_s.sub(/^:+/,''))
          Severity: Minor
          Found in lib/rdf/model/uri.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 a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(value, datatype: nil, lexical: nil, **options)
                @datatype = RDF::URI(datatype || self.class.const_get(:DATATYPE))
                @string   = lexical || (value if value.is_a?(String))
                @object   = case
                  when value.class == ::Date
          Severity: Minor
          Found in lib/rdf/model/literal/date.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 parse has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.parse(files, evaluate: nil, format: nil, encoding: Encoding::UTF_8, **options, &block)
                if files.empty?
                  # If files are empty, either use options[:execute]
                  input = evaluate ? StringIO.new(evaluate) : $stdin
                  input.set_encoding(encoding )
          Severity: Minor
          Found in lib/rdf/cli.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 options has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.options(argv, format: nil)
                options = OptionParser.new
                cli_opts = OPTIONS.map(&:dup)
                logger = Logger.new($stderr)
                logger.level = Logger::WARN
          Severity: Minor
          Found in lib/rdf/cli.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 join has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def join(*uris)
                joined_parts = object.dup.delete_if {|k, v| %i(user password host port).include?(k)}
          
                uris.each do |uri|
                  uri = RDF::URI.new(uri) unless uri.is_a?(RDF::URI)
          Severity: Minor
          Found in lib/rdf/model/uri.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 a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(value, datatype: nil, lexical: nil, **options)
                @datatype = RDF::URI(datatype || self.class.const_get(:DATATYPE))
                @string   = lexical || (value if value.is_a?(String))
                @object   = case
                  when value.is_a?(::DateTime)
          Severity: Minor
          Found in lib/rdf/model/literal/datetime.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 delete_from has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

                def delete_from(data, statement)
                  if has_statement_in?(data, statement)
                    s, p, o, g = statement.to_quad
                    g = DEFAULT_GRAPH unless supports?(:graph_name)
                    g ||= DEFAULT_GRAPH
          Severity: Minor
          Found in lib/rdf/repository.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 adjust_to_timezone! has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def adjust_to_timezone!(*args)
                zone = args.empty? ? '+00:00' : args.first
                if zone.to_s.empty?
                  # Remove timezone component
                  @object = self.class.new(@object.strftime(self.class.const_get(:FORMAT))).object
          Severity: Minor
          Found in lib/rdf/model/literal/temporal.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 filter has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def filter(criteria = {})
                @variable_names = nil
                if block_given?
                  self.reject! do |solution|
                    !yield(solution.is_a?(Solution) ? solution : Solution.new(solution))
          Severity: Minor
          Found in lib/rdf/query/solutions.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 read_uriref has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def read_uriref(intern: false, **options)
                if uri_str = match(URIREF)
                  uri_str = self.class.unescape(uri_str)
                  uri = RDF::URI.send(intern? && intern ? :intern : :new, uri_str)
                  uri.validate!     if validate?
          Severity: Minor
          Found in lib/rdf/ntriples/reader.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 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 []= 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

          Severity
          Category
          Status
          Source
          Language