Showing 109 of 109 total issues

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
Severity: Minor
Found in app/controllers/user_sessions_controller.rb - About 55 mins 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 build_from_rdf has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def self.build_from_rdf(rdf_subject, rdf_predicate, rdf_object)
    raise "#{self.name}#build_from_rdf: Subject (#{rdf_subject}) must be a Concept." unless rdf_subject.is_a? Concept::Base
    raise "#{self.name}#build_from_rdf: Object (#{rdf_object}) must be a Concept."   unless rdf_object.is_a? Concept::Base

    relation_class = RDFAPI::PREDICATE_DICTIONARY[rdf_predicate] || self
Severity: Minor
Found in app/models/concept/relation/skos/base.rb - About 55 mins 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 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

Severity: Minor
Found in app/helpers/navigation_helper.rb - About 55 mins 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 distinct_versions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def distinct_versions
    query = self.class.by_origin(origin)
    existing_total = query.count
    if existing_total >= 2
      errors.add :base, I18n.t('txt.models.concept.version_error', origin: origin)
Severity: Minor
Found in app/models/concerns/first_level_object_validations.rb - About 45 mins 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 concept has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.concept(options={})
    attributes = options[:concept_attributes] || {}
    pref_labels = options[:pref_labels] || []
    alt_labels = options[:alt_labels] || []

Severity: Minor
Found in app/aides/maker.rb - About 45 mins 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 page_header has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def page_header(args = {}, &block)
    if title = args[:title]
      content_for(:title, strip_tags(title))
    end

Severity: Minor
Found in app/helpers/application_helper.rb - About 45 mins 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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    authorize! :update, Iqvoc.config

    # deserialize and save configuration settings
    errors = []
Severity: Minor
Found in app/controllers/instance_configuration_controller.rb - About 45 mins 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 import has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def import(file)
    ActiveSupport.run_load_hooks(:skos_importer_before_import, self)

    start = Time.now

Severity: Minor
Found in app/aides/skos_importer.rb - About 45 mins 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 build_from_rdf has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.build_from_rdf(rdf_subject, rdf_predicate, rdf_object)
    raise "#{self.name}#build_from_rdf: Subject (#{rdf_subject}) must be a Collection."          unless rdf_subject.is_a?(Collection::Base)
    raise "#{self.name}#build_from_rdf: Object (#{rdf_object}) must be a Collection or Concept." unless rdf_object.is_a?(Collection::Base) or rdf_object.is_a?(Concept::Base)

    member_instance = rdf_subject.members.detect{ |rel| rel.target == rdf_object }
Severity: Minor
Found in app/models/collection/member/skos/base.rb - About 45 mins 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 valid? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def valid?
    valid = true

    if blank_node = initial_value.match(RDFAPI::BLANK_NODE_REGEXP)
      # blank node validation, should not contain special chars
Severity: Minor
Found in app/aides/origin.rb - About 45 mins 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 prepare_match has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def prepare_match
    begin
      origin = params.require(:origin)
      @uri = params.require(:uri)
      match_class = params.require(:match_class)
Severity: Minor
Found in app/controllers/reverse_matches_controller.rb - About 45 mins 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

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

      empty: function() {
        var el = $("<p />").text(options.noResultsMsg);
        return $("<div />").append(el).html();
      },
Severity: Minor
Found in app/assets/javascripts/iqvoc/autocomplete.js and 1 other location - About 40 mins to fix
app/assets/javascripts/iqvoc/autocomplete.js on lines 30..33

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 49.

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

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

      suggestion: function(item) {
        var el = $("<p />").text(item.label);
        return $("<div />").append(el).html();
      }
Severity: Minor
Found in app/assets/javascripts/iqvoc/autocomplete.js and 1 other location - About 40 mins to fix
app/assets/javascripts/iqvoc/autocomplete.js on lines 26..29

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 49.

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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def initialize(object, default_namespace_url, logger = Rails.logger, publish = true, verbose = false)
Severity: Minor
Found in app/aides/skos_importer.rb - About 35 mins to fix

    Method populate_hierarchy has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def populate_hierarchy(root_concept, scope, max_depth, current_depth = 0,
            include_siblings = false)
    Severity: Minor
    Found in app/controllers/hierarchy_controller.rb - About 35 mins to fix

      Method add_collections has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def add_collections(document)
          @logger.info 'Exporting collections...'
      
          offset = 0
          while true
      Severity: Minor
      Found in app/aides/skos_exporter.rb - About 35 mins 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 pref_label has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def pref_label
          if pref_labels.loaded?
            # use select if association is already loaded
            @cached_pref_labels ||= pref_labels.select(&:published?).each_with_object({}) do |label, hash|
              if hash[label.language]
      Severity: Minor
      Found in app/models/concept/base.rb - About 35 mins 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 index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def index
          authorize! :read, Concept::Base
      
          # only initilaize dataset if dataset param is set
          # prevent obsolet http request when using matches widget
      Severity: Minor
      Found in app/controllers/concepts/alphabetical_controller.rb - About 35 mins 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 show has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def show
          published = params[:published] == '1' || !params[:published]
          scope = Iqvoc::Collection.base_class.by_origin(params[:id])
      
          if published
      Severity: Minor
      Found in app/controllers/collections_controller.rb - About 35 mins 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 add_concepts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def add_concepts(document)
          @logger.info 'Exporting concepts...'
      
          offset = 0
          while true
      Severity: Minor
      Found in app/aides/skos_exporter.rb - About 35 mins 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

      Severity
      Category
      Status
      Source
      Language