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|
Severity: Minor
Found in app/helpers/rdf_helper.rb - About 1 hr to fix

    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))
    Severity: Minor
    Found in app/models/note/skos/change_note.rb - About 1 hr 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_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|
    Severity: Minor
    Found in app/helpers/rdf_helper.rb - About 1 hr 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 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
    Severity: Minor
    Found in app/aides/skos_importer.rb - About 1 hr to fix

      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)
      Severity: Minor
      Found in app/models/note/base.rb - About 1 hr to fix

        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) }
        Severity: Minor
        Found in app/models/collection/base.rb - About 1 hr 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 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
        Severity: Minor
        Found in app/assets/javascripts/iqvoc/autocomplete.js - About 1 hr to fix

          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
          Severity: Minor
          Found in app/controllers/concepts/versions_controller.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in app/controllers/rdf_controller.rb - About 1 hr to fix

              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)
              Severity: Major
              Found in app/models/dataset/adaptors/iqvoc/search_adaptor.rb and 1 other location - About 1 hr to fix
              app/models/dataset/adaptors/iqvoc/alphabetical_search_adaptor.rb on lines 7..19

              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

              Further Reading

              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)
              app/models/dataset/adaptors/iqvoc/search_adaptor.rb on lines 19..31

              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

              Further Reading

              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)
              Severity: Minor
              Found in app/helpers/dashboard_helper.rb - About 1 hr 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_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
              Severity: Minor
              Found in app/helpers/navigation_helper.rb - About 1 hr 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 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
              Severity: Minor
              Found in app/jobs/reverse_match_job.rb - About 1 hr 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 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
              Severity: Minor
              Found in app/controllers/concepts_movement_controller.rb - About 1 hr 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 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)
              Severity: Minor
              Found in app/models/note/base.rb - About 1 hr 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 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
              Severity: Minor
              Found in lib/iqvoc/environments/development.rb - About 1 hr to fix

                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
                Severity: Minor
                Found in app/controllers/concepts_movement_controller.rb - About 1 hr to fix

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

                  Severity
                  Category
                  Status
                  Source
                  Language