ruby-rdf/rdf

View on GitHub

Showing 213 of 213 total issues

Method open_url has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.open_url(base_uri, proxy: nil, headers: {}, verify_none: false, **options)
        ssl_verify = verify_none ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER

        redirect_count = 0
        max_redirects = 5
Severity: Minor
Found in lib/rdf/util/file.rb - About 1 hr to fix

    Method query_pattern has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def query_pattern(pattern, **options, &block)
            snapshot = @data
            if block_given?
              graph_name  = pattern.graph_name
              subject     = pattern.subject
    Severity: Minor
    Found in lib/rdf/repository.rb - About 1 hr to fix

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

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

        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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                    attributes[ak] = avs.map do |av|
                      l = RDF::List.new(subject: av, graph: graph)
                      if l.valid?
                        RDF::List.new(subject: av) do |nl|
                          l.each do |lv|
        Severity: Major
        Found in lib/rdf/vocabulary.rb and 1 other location - About 1 hr to fix
        lib/rdf/vocabulary.rb on lines 562..574

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 65.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                    attributes[ak] = avs.is_a?(Array) ? (avs.map do |av|
                      l = RDF::List.new(subject: av, graph: graph)
                      if l.valid?
                        RDF::List.new(subject: av) do |nl|
                          l.each do |lv|
        Severity: Major
        Found in lib/rdf/vocabulary.rb and 1 other location - About 1 hr to fix
        lib/rdf/vocabulary.rb on lines 542..554

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 65.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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
                      Severity
                      Category
                      Status
                      Source
                      Language