Showing 109 of 109 total issues

Function Treeview has 199 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function Treeview(container) {
    this.container = container.jquery ? container : $(container);

    $(container).each(function() {
      var url = $(this).data('url');
Severity: Major
Found in app/assets/javascripts/iqvoc/treeview.js - About 7 hrs to fix

    File base.rb has 407 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Concept::Base < ApplicationRecord
      attr_accessor :reverse_match_service
      self.table_name = 'concepts'
    
      class_attribute :default_includes
    Severity: Minor
    Found in app/models/concept/base.rb - About 5 hrs to fix

      Function EntitySelector has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

      IQVOC.EntitySelector = (function($) {
      
      "use strict";
      
      var EntitySelector = function(node) {
      Severity: Minor
      Found in app/assets/javascripts/iqvoc/entityselect.js - About 5 hrs 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

      Function EntitySelector has 143 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      IQVOC.EntitySelector = (function($) {
      
      "use strict";
      
      var EntitySelector = function(node) {
      Severity: Major
      Found in app/assets/javascripts/iqvoc/entityselect.js - About 5 hrs to fix

        Method index has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
        Open

          def index
            base_class = Iqvoc::Concept.base_class
        
            if params[:published] == '0'
              authorize! :update, base_class
        Severity: Minor
        Found in app/controllers/concepts/hierarchical_controller.rb - About 5 hrs 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 render_hierarchy has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

          def render_hierarchy(root_origin, depth, unbounded = false)
            default_depth = 3
            max_depth = 4 # XXX: arbitrary
        
            direction = params[:dir] == 'up' ? 'up' : 'down'
        Severity: Minor
        Found in app/controllers/hierarchy_controller.rb - About 4 hrs 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

        Class Base has 33 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Concept::Base < ApplicationRecord
          attr_accessor :reverse_match_service
          self.table_name = 'concepts'
        
          class_attribute :default_includes
        Severity: Minor
        Found in app/models/concept/base.rb - About 4 hrs to fix

          Method index has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

            def index
              authorize! :read, Concept::Base
              # TODO: requires a dedicated :search permission because this covers more
              # than just concepts
          
          
          Severity: Minor
          Found in app/controllers/search_results_controller.rb - About 3 hrs 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 single_query has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.single_query(params = {})
              query_str = build_query_string(params)
          
              scope = includes(:target).order(Arel.sql("LENGTH(#{Label::Base.table_name}.value), #{Label::Base.table_name}.value ASC"))
              languages = Array(params[:languages])
          Severity: Minor
          Found in app/models/labeling/skos/base.rb - About 3 hrs 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_rdf has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

            def build_rdf(document, subject)
              if annotations.any?
                subject.send(rdf_namespace).build_predicate(rdf_predicate) do |blank_node|
                  blank_node.Rdfs::comment(value, lang: language || nil) if value
                  annotations.order(:namespace, :predicate).each do |annotation|
          Severity: Minor
          Found in app/models/note/skos/base.rb - About 3 hrs 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_second_level_objects has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

            def import_second_level_objects(types, final, line)
              subject, predicate, object = *extract_triple(line)
          
              return unless (subject =~ /^:(.*)$/ && types[predicate]) # We're not responsible for this
          
          
          Severity: Minor
          Found in app/aides/skos_importer.rb - About 2 hrs 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 single_query has 70 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.single_query(params = {})
              query_str = build_query_string(params)
          
              scope = includes(:target).order(Arel.sql("LENGTH(#{Label::Base.table_name}.value), #{Label::Base.table_name}.value ASC"))
              languages = Array(params[:languages])
          Severity: Major
          Found in app/models/labeling/skos/base.rb - About 2 hrs to fix

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

                  teaserLink.on('click', function(ev) {
                    ev.preventDefault();
            
                    var modal = $("#concept-teaser-modal");
                    var target = $(this).attr("href");
            Severity: Major
            Found in app/assets/javascripts/iqvoc/treeview.js and 1 other location - About 2 hrs to fix
            app/assets/javascripts/iqvoc/iqvoc.js on lines 98..108

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

            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

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

              $(".dashboard-glance-link").on('click', function(ev) {
                ev.preventDefault();
            
                var modal = $("#concept-teaser-modal");
                var target = $(this).attr("href");
            Severity: Major
            Found in app/assets/javascripts/iqvoc/iqvoc.js and 1 other location - About 2 hrs to fix
            app/assets/javascripts/iqvoc/treeview.js on lines 251..261

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

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

              def self.from_yaml(yml)
                data = YAML.load(yml)
            
                labels = {}
                data['labels'].each { |label| # XXX: use omap to simplify format (making `value` the key instead of an attribute)?
            Severity: Minor
            Found in app/aides/maker.rb - About 2 hrs 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 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def show
                get_concept
                authorize! :read, @concept
            
                if params[:full_consistency_check] && can?(:check_consistency, @concept)
            Severity: Major
            Found in app/controllers/concepts_controller.rb - About 2 hrs to fix

              File skos_importer.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              class SkosImporter
                class_attribute :first_level_object_classes, :second_level_object_classes
                self.first_level_object_classes = [
                  Iqvoc::Concept.base_class,
                  Iqvoc::Collection.base_class
              Severity: Minor
              Found in app/aides/skos_importer.rb - About 2 hrs to fix

                Class Base has 22 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class Collection::Base < Concept::Base
                
                  Iqvoc::Collection.include_modules.each do |mod|
                    include mod
                  end
                Severity: Minor
                Found in app/models/collection/base.rb - About 2 hrs to fix

                  Function LanguageSelector has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  IQVOC.LanguageSelector = (function($) {
                  
                  "use strict";
                  
                  var getSelection, setSelection;
                  Severity: Major
                  Found in app/assets/javascripts/iqvoc/langselect.js - About 2 hrs to fix

                    Method merge has a Cognitive Complexity of 17 (exceeds 5 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
                    Severity: Minor
                    Found in app/controllers/concepts/versions_controller.rb - About 2 hrs 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