Showing 188 of 213 total issues
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?/)
- 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 11 (exceeds 5 allowed). Consider refactoring. Open
def initialize(value, language: nil, datatype: nil, direction: nil, lexical: nil, validate: false, canonicalize: false, **options)
@object = value.freeze
@string = lexical if lexical
@string = value if !defined?(@string) && value.is_a?(String)
@string = @string.encode(Encoding::UTF_8).freeze if instance_variable_defined?(:@string)
- 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 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
- 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 each_statement
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def each_statement
attributes.keys.each do |p|
prop = ATTR_URIs.fetch(p) { RDF::Vocabulary::expand_pname(p)}
values = attribute_value(p)
values = [values].compact unless values.is_a?(Array)
- 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 each
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def each(&block)
if self.equal?(Vocabulary)
if instance_variable_defined?(:@vocabs) && @vocabs
@vocabs.select(&:name).each(&block)
else
- 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 new
has 31 lines of code (exceeds 25 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
Method to_ruby
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_ruby(indent: "")
"term(" +
(self.uri? ? self.to_s.inspect + ",\n" : "\n") +
"#{indent} " +
attributes.keys.sort.map do |k|
Method write_statement
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def write_statement(statement)
statement = statement.canonicalize! if canonicalize?
# Make sure BNodes in statement use unique identifiers
if statement.node?
Method escape
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.escape(string, encoding = nil)
ret = case
when string.match?(ESCAPE_PLAIN) # a shortcut for the simple case
string
when string.ascii_only?
Method content_type
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.content_type(type = nil, options = {})
if type.nil?
[@@content_type[self], @@content_types.map {
|ct, cl| (cl.include?(self) && ct != @@content_type[self]) ? ct : nil }].flatten.compact
else
Method initialize
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(body, options = {})
options.each do |key, value|
# de-quote charset
matchdata = value.match(/^["'](.*)["']$/.freeze) if key == "charset"
value = matchdata[1] if matchdata
Method open
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.open(filename, format: nil, **options, &block)
# If we're the abstract reader, and we can figure out a concrete reader from format, use that.
if self == RDF::Reader && format && reader = self.for(format)
return reader.open(filename, format: format, **options, &block)
end
Method initialize!
has 29 lines of code (exceeds 25 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)
Method []=
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def []=(*args)
start, length = 0, 0
ary = self.to_a
Method normalized_path
has 28 lines of code (exceeds 25 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}"
Method commands
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.commands(format: nil, **options)
# First, load commands from other formats
load_commands
case format
Method /
has 28 lines of code (exceeds 25 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(/^:+/,''))
Method serialize_value
has 28 lines of code (exceeds 25 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
Method initialize
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def initialize(name = nil, value = nil, distinguished: nil, existential: nil)
name = (name || "g#{__id__.to_i.abs}").to_s
if name.start_with?('??')
name, dis, ex = name[2..-1], false, false
elsif name.start_with?('?')
- 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 for
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.for(*arg, &block)
case arg.length
when 0 then arg = nil
when 1 then arg = arg.first
else
- 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"