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'
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)
- Read upRead up
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
File literal.rb
has 282 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'bcp47_spec'
module RDF
##
# An RDF literal.
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)
- Read upRead up
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 Format
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Format
extend ::Enumerable
##
# Enumerates known RDF serialization format classes.
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)
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
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])
- Read upRead up
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)
- Read upRead up
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)
- Read upRead up
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"
- Read upRead up
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
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,
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|
- Read upRead up
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
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#>
# #
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
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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"