Showing 213 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 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 Format
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Format
extend ::Enumerable
##
# Enumerates known RDF serialization format classes.
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!
@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 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 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
Similar blocks of code found in 3 locations. Consider refactoring. Open
def -(other)
if self.class == Double || [Double, ::Float].include?(other.class)
RDF::Literal::Double.new(to_f - other.to_f)
elsif ((self.class == RDF::Literal::Float || other.class == RDF::Literal::Float) rescue false)
RDF::Literal::Float.new(to_f - other.to_f)
- Read upRead up
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 81.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
def *(other)
if self.class == Double || [Double, ::Float].include?(other.class)
RDF::Literal::Double.new(to_f * other.to_f)
elsif ((self.class == RDF::Literal::Float || other.class == RDF::Literal::Float) rescue false)
RDF::Literal::Float.new(to_f * other.to_f)
- Read upRead up
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 81.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
def +(other)
if self.class == Double || [Double, ::Float].include?(other.class)
RDF::Literal::Double.new(to_f + other.to_f)
elsif ((self.class == RDF::Literal::Float || other.class == RDF::Literal::Float) rescue false)
RDF::Literal::Float.new(to_f + other.to_f)
- Read upRead up
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 81.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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#>
# #