Showing 109 of 109 total issues
Method render_concept
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render_concept(document, concept, suppress_extra_labels = false)
# You can not eager load polymorphic associations. That's why we're loading
# the collections _one_ time and remember them for further _render_concept_
# calls in the future.
@rdf_helper_cached_collections ||= Iqvoc::Collection.base_class.select('id, origin').load.each_with_object({}) do |c, hash|
Method build_rdf
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def build_rdf(document, subject)
subject.send(self.rdf_namespace).build_predicate(self.rdf_predicate) do |blank_node|
blank_node.Rdfs::comment(self.value, lang: self.language || nil) if self.value
self.annotations.order(:namespace, :predicate).each do |annotation|
if (IqRdf::Namespace.find_namespace_class(annotation.namespace))
- 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 render_concept
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def render_concept(document, concept, suppress_extra_labels = false)
# You can not eager load polymorphic associations. That's why we're loading
# the collections _one_ time and remember them for further _render_concept_
# calls in the future.
@rdf_helper_cached_collections ||= Iqvoc::Collection.base_class.select('id, origin').load.each_with_object({}) do |c, hash|
- 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 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(object, default_namespace_url, logger = Rails.logger, publish = true, verbose = false)
@file = case object
when File
File.open(object)
when Array
Method single_query
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.single_query(params = {})
query_str = build_query_string(params)
scope = by_query_value(query_str).
by_language(params[:languages].to_a)
Method regenerate_members
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def regenerate_members(target_class, target_origins)
return if target_origins.nil? # There is nothing to do
existing = self.members.includes(:target)
existing = if target_class <= Collection::Base
existing.select { |m| m.target.is_a?(Collection::Base) }
- 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
Function autocomplete
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
IQVOC.autocomplete = (function($) {
// `field` is the input field to be augmented
// `source` is a function expected to calculate the results - it is invoked with
// the respective query string and a callback and expected to invoke that
Method merge
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def merge
concept_scope = Iqvoc::Concept.base_class.by_origin(params[:origin])
current_concept = concept_scope.published.last
new_version = concept_scope.unpublished.last
Method show
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
scope = if params[:published] == '0'
Iqvoc::Concept.base_class.unpublished
else
Iqvoc::Concept.base_class.published
Similar blocks of code found in 2 locations. Consider refactoring. Open
def fetch_results(path, params = {})
begin
response = @conn.get(path, params)
@results ||= []
@results += extract_results(response.body)
- 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 51.
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 2 locations. Consider refactoring. Open
def fetch_results(url, params = {})
begin
response = @conn.get(url, params)
@results ||= []
@results += extract_results(response.body)
- 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 51.
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
Method link_to_dashboard_item
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def link_to_dashboard_item(item)
if item.is_a?(Label::Base)
item.published? ? label_path(id: item.origin) : label_path(published: 0, id: item.origin)
elsif item.is_a?(Collection::Base)
item.published? ? collection_path(id: item.origin) : collection_path(published: 0, id: item.origin)
- 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 nav_link
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def nav_link(item, opts = {})
active = item[:active?] ? instance_eval(&item[:active?]) : (item[:controller] ? params[:controller] == item[:controller] : false)
css = opts[:class] || 'nav-link'
css << ' active' if active
- 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 error
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def error(job, exception)
error_type = nil
case exception
when Faraday::ConnectionFailed
- 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 move
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def move
moved_concept = Iqvoc::Concept.base_class.find(params.require(:moved_node_id))
if moved_concept.published?
authorize! :branch, moved_concept
- 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 single_query
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.single_query(params = {})
query_str = build_query_string(params)
scope = by_query_value(query_str).
by_language(params[:languages].to_a)
- 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 setup_development
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.setup_development(config)
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for development
Method move
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def move
moved_concept = Iqvoc::Concept.base_class.find(params.require(:moved_node_id))
if moved_concept.published?
authorize! :branch, moved_concept
Method sidebar_item
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def sidebar_item(opts = {}, &block)
if perms = opts.delete(:perms)
return nil if cannot?(*perms)
end
- 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 create
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create
authorize! :create, UserSession
@user_session = UserSession.new(user_session_params.to_h)
request.session_options[:skip] = false
- 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"