Showing 109 of 109 total issues

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

    def unique_pref_labels
      if validatable_for_publishing?
        # checks if any other concept already owns the chosen pref labels
        conflicting_pref_labels = pref_labels.select do |l|
          Iqvoc::Concept.base_class.joins(:pref_labels).where(labels: { value: l.value, language: l.language }).where('labelings.owner_id != ?', id).where('concepts.origin != ?', origin).any?
Severity: Minor
Found in app/models/concept/validations.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 build_from_rdf has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.build_from_rdf(rdf_subject, rdf_predicate, rdf_object)
    # https://github.com/rails/rails/issues/16928
    unless rdf_subject.class.reflections.include?(self.name.to_relation_name.to_s)
      raise "#{self.name}#build_from_rdf: Subject (#{rdf_subject}) must be able to receive this kind of note (#{self.name} => #{self.name.to_relation_name.to_s})."
    end
Severity: Minor
Found in app/models/note/skos/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_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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    @user = User.find(params[:id])
    authorize! :update, @user

    # strip out role and active params so that a non admin
Severity: Minor
Found in app/controllers/users_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

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

      sort = params[:sort].split(',').select { |s| s.include? 'state ' }.last.gsub('state ', '')
      collections = collections.to_a.sort_by { |c| c.state }
      collections = sort == 'DESC' ? collections.reverse : collections
    elsif params[:sort]
Severity: Minor
Found in app/controllers/dashboard_controller.rb and 1 other location - About 30 mins to fix
app/controllers/dashboard_controller.rb on lines 24..27

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

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

      sort = params[:sort].split(',').select { |s| s.include? 'state ' }.last.gsub('state ', '')
      concepts = concepts.to_a.sort_by { |c| c.state }
      concepts = sort == 'DESC' ? concepts.reverse : concepts
    elsif params[:sort]
Severity: Minor
Found in app/controllers/dashboard_controller.rb and 1 other location - About 30 mins to fix
app/controllers/dashboard_controller.rb on lines 49..52

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

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

Avoid too many return statements within this method.
Open

        return Float(str)
Severity: Major
Found in app/controllers/instance_configuration_controller.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        render_response :in_processing and return if unpublished_concepts.any?
    Severity: Major
    Found in app/controllers/reverse_matches_controller.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return str.to_i
      Severity: Major
      Found in app/controllers/instance_configuration_controller.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              render_response :unknown_referer and return
        Severity: Major
        Found in app/controllers/reverse_matches_controller.rb - About 30 mins to fix

          Method render_match_association has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def render_match_association(hash, concept, association_classes, further_options = {})
              matches_html = ''
              association_classes.each do |association_class|
                matches_html += if association_class.respond_to?(:hidden?) && association_class.hidden?(concept)
                  ''
          Severity: Minor
          Found in app/helpers/concepts_helper.rb - About 25 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

            self.second_level_object_classes = Iqvoc::Concept.labeling_classes.keys +
              Iqvoc::Concept.note_classes +
              Iqvoc::Concept.relation_classes +
              Iqvoc::Concept.match_classes +
              Iqvoc::Concept.notation_classes +
          Severity: Minor
          Found in app/aides/skos_importer.rb and 1 other location - About 25 mins to fix
          app/aides/rdfapi.rb on lines 19..25

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

          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 build_from_rdf has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.build_from_rdf(rdf_subject, rdf_predicate, rdf_object)
              unless rdf_subject.is_a?(Concept::Base)
                raise "#{self.name}#build_from_rdf: Subject (#{rdf_subject}) must be a Concept."
              end
          
          
          Severity: Minor
          Found in app/models/labeling/skos/base.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def index
              authorize! :read, Concept::Base
          
              respond_to do |format|
                format.html do
          Severity: Minor
          Found in app/controllers/concepts_controller.rb - About 25 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 labels_for_labeling_class_and_language has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def labels_for_labeling_class_and_language(labeling_class, lang = :en, only_published = true)
              # Convert lang to string in case it's not nil.
              # nil values play their own role for labels without a language.
              if lang == 'none'
                lang = nil
          Severity: Minor
          Found in app/models/concept/base.rb - About 25 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 nav_items has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def nav_items(items)
              items.map do |item|
                if nav_item_authorized?(item)
                  if item[:items]
                    content_tag :li, class: 'nav-item dropdown' do
          Severity: Minor
          Found in app/helpers/navigation_helper.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def index
              authorize! :sync, :triplestore
          
              flash.now[:info] = [I18n.t('txt.controllers.triplestore_sync.batch_hint',
                  host: root_url(lang: nil))]
          Severity: Minor
          Found in app/controllers/triplestore_sync_controller.rb - About 25 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

            SECOND_LEVEL_OBJECT_CLASSES = Iqvoc::Concept.labeling_classes.keys +
            Iqvoc::Concept.note_classes +
            Iqvoc::Concept.relation_classes +
            Iqvoc::Concept.match_classes +
            Iqvoc::Concept.notation_classes +
          Severity: Minor
          Found in app/aides/rdfapi.rb and 1 other location - About 25 mins to fix
          app/aides/skos_importer.rb on lines 7..13

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

          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

          Severity
          Category
          Status
          Source
          Language