ruby-rdf/rdf

View on GitHub

Showing 188 of 213 total issues

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 valid? has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def valid?
          (subject?   ? (subject.resource? || subject.variable?) && subject.valid? : true) && 
          (predicate? ? (predicate.uri? || predicate.variable?) && predicate.valid? : true) &&
          (object?    ? (object.term? || object.variable?) && object.valid? : true) &&
          (graph?     ? (graph_name.resource? || graph_name.variable?) && graph_name.valid? : true)
    Severity: Minor
    Found in lib/rdf/query/pattern.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

    File writer.rb has 282 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module RDF
      ##
      # The base class for RDF serializers.
      #
      # @example Loading an RDF writer implementation
    Severity: Minor
    Found in lib/rdf/writer.rb - About 2 hrs to fix

      File literal.rb has 282 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'bcp47_spec'
      
      module RDF
        ##
        # An RDF literal.
      Severity: Minor
      Found in lib/rdf/model/literal.rb - About 2 hrs to fix

        Method read_literal has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def read_literal
              if literal_str = match(LITERAL_PLAIN)
                literal_str = self.class.unescape(literal_str)
                literal = case
                  when lang_dir = match(LANG_DIR)
        Severity: Minor
        Found in lib/rdf/ntriples/reader.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

        Class Pattern has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Pattern < RDF::Statement
            ##
            # @private
            # @since 0.2.2
            def self.from(pattern, graph_name: nil, **options)
        Severity: Minor
        Found in lib/rdf/query/pattern.rb - About 2 hrs to fix

          Class Format has 24 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Format
              extend ::Enumerable
          
              ##
              # Enumerates known RDF serialization format classes.
          Severity: Minor
          Found in lib/rdf/format.rb - About 2 hrs to fix

            Class Graph has 24 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Graph
                include RDF::Value
                include RDF::Countable
                include RDF::Durable
                include RDF::Enumerable
            Severity: Minor
            Found in lib/rdf/model/graph.rb - About 2 hrs to fix

              Method relativize has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  def relativize(base_uri)
                    if self.to_s.start_with?(base_uri.to_s) && %w(# ?).include?(self.to_s[base_uri.to_s.length, 1]) ||
                       base_uri.to_s.end_with?("/", "#") &&
                       self.to_s.start_with?(base_uri.to_s)
                      return RDF::URI(self.to_s[base_uri.to_s.length..-1])
              Severity: Minor
              Found in lib/rdf/model/uri.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 initialize! has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  def initialize!
                    @graph_name = Variable.new(@graph_name) if @graph_name.is_a?(Symbol)
                    @subject    = Variable.new(@subject)    if @subject.is_a?(Symbol)
                    @predicate  = Variable.new(@predicate)  if @predicate.is_a?(Symbol)
                    @object     = Variable.new(@object)     if @object.is_a?(Symbol)
              Severity: Minor
              Found in lib/rdf/query/pattern.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 initialize has a Cognitive Complexity of 18 (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.respond_to?(:to_datetime)
              Severity: Minor
              Found in lib/rdf/model/literal/time.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 from_node has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                    def from_node(name, attributes, term_type)
                      op = case term_type
                      when :property then "property"
                      when :ontology then "ontology"
                      else                "term"
              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

              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
                            graph_name    = read_uriref || read_node
              Severity: Critical
              Found in lib/rdf/nquads.rb - About 2 hrs to fix

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

                    def self.options
                      [
                        RDF::CLI::Option.new(
                          symbol: :base_uri,
                          control: :url,
                Severity: Major
                Found in lib/rdf/reader.rb - About 2 hrs to fix

                  Method query_values has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def query_values(return_type=Hash)
                        raise ArgumentError, "Invalid return type. Must be Hash or Array." unless [Hash, Array].include?(return_type)
                        return nil if query.nil?
                        query.to_s.split('&').
                          inject(return_type == Hash ? {} : []) do |memo,kv|
                  Severity: Minor
                  Found in lib/rdf/model/uri.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

                  File repository.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  module RDF
                    ##
                    # An RDF repository.
                    #
                    # @example Creating a transient in-memory repository
                  Severity: Minor
                  Found in lib/rdf/repository.rb - About 2 hrs to fix

                    File xsd.rb has 254 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    require 'rdf'
                    module RDF
                      # @!parse
                      #   # Vocabulary for <http://www.w3.org/2001/XMLSchema#>
                      #   #
                    Severity: Minor
                    Found in lib/rdf/vocab/xsd.rb - About 2 hrs to fix

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language