ncbo/bioportal_web_ui

View on GitHub
app/controllers/ontologies_controller.rb

Summary

Maintainability
D
2 days
Test Coverage

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

  def index
    @app_name = "FacetedBrowsing"
    @app_dir = "/browse"
    @base_path = @app_dir
    ontologies = LinkedData::Client::Models::Ontology.all(include: LinkedData::Client::Models::Ontology.include_params + ",viewOf", include_views: true, display_context: false)
Severity: Minor
Found in app/controllers/ontologies_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

File ontologies_controller.rb has 318 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class OntologiesController < ApplicationController
  include MappingsHelper
  include MappingStatistics

  require "multi_json"
Severity: Minor
Found in app/controllers/ontologies_controller.rb - About 3 hrs to fix

    Method show has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      def show
        # Hack to make ontologyid and conceptid work in addition to id and ontology params
        params[:id] = params[:id].nil? ? params[:ontologyid] : params[:id]
        params[:ontology] = params[:ontology].nil? ? params[:id] : params[:ontology]
    
    
    Severity: Minor
    Found in app/controllers/ontologies_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 index has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def index
        @app_name = "FacetedBrowsing"
        @app_dir = "/browse"
        @base_path = @app_dir
        ontologies = LinkedData::Client::Models::Ontology.all(include: LinkedData::Client::Models::Ontology.include_params + ",viewOf", include_views: true, display_context: false)
    Severity: Major
    Found in app/controllers/ontologies_controller.rb - About 2 hrs to fix

      Method show has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def show
          # Hack to make ontologyid and conceptid work in addition to id and ontology params
          params[:id] = params[:id].nil? ? params[:ontologyid] : params[:id]
          params[:ontology] = params[:ontology].nil? ? params[:id] : params[:ontology]
      
      
      Severity: Major
      Found in app/controllers/ontologies_controller.rb - About 2 hrs to fix

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

          def classes
            get_class(params)
        
            if ["application/ld+json", "application/json"].include?(request.accept)
              render plain: @concept.to_jsonld, content_type: request.accept and return
        Severity: Minor
        Found in app/controllers/ontologies_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

        Avoid too many return statements within this method.
        Open

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

          Avoid too many return statements within this method.
          Open

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

            Avoid too many return statements within this method.
            Open

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

              Avoid too many return statements within this method.
              Open

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

                Avoid too many return statements within this method.
                Open

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

                  Avoid too many return statements within this method.
                  Open

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

                    Avoid too many return statements within this method.
                    Open

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

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

                        def update
                          if params['commit'] == 'Cancel'
                            acronym = params['id']
                            redirect_to "/ontologies/#{acronym}"
                            return
                      Severity: Minor
                      Found in app/controllers/ontologies_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

                      There are no issues that match your filters.

                      Category
                      Status