ruby-rdf/rdf

View on GitHub

Showing 188 of 213 total issues

Method insert_to has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def insert_to(data, statement)
        raise ArgumentError, "Statement #{statement.inspect} is incomplete" if statement.incomplete?

        unless statement_in?(data, statement)
          s, p, o, c = statement.to_quad
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 query_values= has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def query_values=(value)
      if value.nil?
        self.query = nil
        return
      end
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 normalized_path has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def normalized_path
      if normalized_scheme == "urn"
        # Special-case URI. Normalize the NID component only
        nid, p = path.to_s.split(':', 2)
        return "#{nid.downcase}:#{p}"
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 format_uri has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def format_uri(uri, **options)
      string = uri.to_s
      iriref = case
        when string.match?(ESCAPE_PLAIN_U) # a shortcut for the simple case
          string
Severity: Minor
Found in lib/rdf/ntriples/writer.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 open_file has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.open_file(filename_or_url, proxy: nil, headers: {}, verify_none: false, **options, &block)
      filename_or_url = $1 if filename_or_url.to_s.match(/^file:(.*)$/)
      remote_document = nil

      if filename_or_url.to_s.match?(/^https?/)
Severity: Minor
Found in lib/rdf/util/file.rb - About 1 hr to fix

    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 attribute_value has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def attribute_value(prop)
              values = attributes[prop]
              return nil if values.nil?
              values = [values].compact unless values.is_a?(Array)
              prop_values = values.map do |value|
      Severity: Minor
      Found in lib/rdf/vocabulary.rb - About 1 hr to fix

        Method commands has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.commands(format: nil, **options)
              # First, load commands from other formats
              load_commands
        
              case format
        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 solution has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def solution(statement)
              RDF::Query::Solution.new do |solution|
                solution[subject.to_sym]    = statement.subject    if subject.is_a?(Variable)
                solution[predicate.to_sym]  = statement.predicate  if predicate.is_a?(Variable)
                solution[object.to_sym]     = statement.object     if object.is_a?(Variable)
        Severity: Minor
        Found in lib/rdf/query/pattern.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 variable_terms has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def variable_terms(name = nil)
              warn "[DEPRECATION] RDF::Query::Pattern#variable_terms is deprecated and will be removed in a future version.\n" +
                   "Called from #{Gem.location_of_caller.join(':')}"
              terms = []
              terms << :subject    if subject.is_a?(Variable)    && (!name || name.eql?(subject.name))
        Severity: Minor
        Found in lib/rdf/query/pattern.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 expand_pname has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def expand_pname(pname)
                return pname unless pname.is_a?(String) || pname.is_a?(Symbol)
                prefix, suffix = pname.to_s.split(":", 2)
                # Unescape escaped PN_ESCAPE_CHARS
                if suffix.match?(RDF::URI::PN_ESCAPES)
        Severity: Minor
        Found in lib/rdf/vocabulary.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 format_uri has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def format_uri(uri, **options)
              string = uri.to_s
              iriref = case
                when string.match?(ESCAPE_PLAIN_U) # a shortcut for the simple case
                  string
        Severity: Minor
        Found in lib/rdf/ntriples/writer.rb - About 1 hr to fix

          Method query has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def query(pattern, **options, &block)
                raise TypeError, "#{self} is not readable" if respond_to?(:readable?) && !readable?
          
                case pattern
                  # A basic graph pattern (BGP) query:
          Severity: Minor
          Found in lib/rdf/mixin/queryable.rb - About 1 hr to fix

            Method new has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def self.new(*args, vocab: nil, attributes: {}, **options)
                    klass = if args.first.nil?
                      RDF::Node
                    elsif args.first.is_a?(Hash)
                      args.unshift(nil)
            Severity: Minor
            Found in lib/rdf/vocabulary.rb - About 1 hr to fix

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

                  def self.options
                    [
                      RDF::CLI::Option.new(
                        symbol: :canonicalize,
                        datatype: TrueClass,
              Severity: Minor
              Found in lib/rdf/writer.rb - About 1 hr to fix

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

                    def self.each(file_name: nil,
                                  file_extension: nil,
                                  content_type: nil,
                                  has_reader: false,
                                  has_writer: false,
                Severity: Minor
                Found in lib/rdf/format.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 valid? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def valid?
                          BCP47.parse(language.to_s) if language?
                          return false if direction? && !%i{ltr rtl}.include?(direction)
                          return false if datatype? && datatype.invalid?
                          grammar = self.class.const_get(:GRAMMAR) rescue nil
                    Severity: Minor
                    Found in lib/rdf/model/literal.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 open_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def self.open_file(filename_or_url, proxy: nil, headers: {}, verify_none: false, **options, &block)
                          filename_or_url = $1 if filename_or_url.to_s.match(/^file:(.*)$/)
                          remote_document = nil
                    
                          if filename_or_url.to_s.match?(/^https?/)
                    Severity: Minor
                    Found in lib/rdf/util/file.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_triple has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def read_triple
                            loop do
                              readline.strip! # EOFError thrown on end of input
                              line = @line    # for backtracking input in case of parse error
                    
                    
                    Severity: Minor
                    Found in lib/rdf/nquads.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