ontohub/ontohub

View on GitHub

Showing 107 of 107 total issues

Method ontology_nav has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def ontology_nav(ontology, current_page)
    resource = resource_chain.last

    content_page = ontology.distributed? ? :children : :symbols
    @top_level_pages = [
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 commits_path has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def commits_path(walker, limit, offset, path, &block)
    commits = []

    object = nil
    commit = nil
Severity: Minor
Found in lib/git_repository/history.rb - About 1 hr to fix

    Method suspended_save_ontologies has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def suspended_save_ontologies(options={})
        versions = []
        commits_count = 0
        highest_change_file_count = 0
        user = options.delete(:user)
    Severity: Minor
    Found in lib/ontology_saver.rb - About 1 hr to fix

      Method start_element has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def start_element(name, attributes)
            @path << name
            case name
            when ROOT
              callback(:root, Hash[*[attributes]])
      Severity: Minor
      Found in lib/ontology_parser.rb - About 1 hr to fix

        Method end_element has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def end_element(name)
              @path.pop
        
              case name
              when ONTOLOGY
        Severity: Minor
        Found in lib/ontology_parser.rb - About 1 hr to fix

          Method do_or_set_failed has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def do_or_set_failed(updating_klass = nil, &block)
              raise ArgumentError.new('No block given.') unless block_given?
          
              begin
                yield
          Severity: Minor
          Found in lib/state_updater.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

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

                def axiom(current_element)
                  if logic_callback.pre_axiom(current_element)
                    axiom = ontology.axioms.update_or_create_from_hash(
                      current_element, importer.now)
                    ontology.axioms_count += 1
          Severity: Major
          Found in lib/hets/dg/node_evaluator.rb and 1 other location - About 1 hr to fix
          lib/hets/dg/node_evaluator.rb on lines 149..170

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

          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 theorem(current_element)
                  if logic_callback.pre_theorem(current_element)
                    theorem = ontology.theorems.update_or_create_from_hash(
                      current_element, importer.now)
                    ontology.theorems_count += 1
          Severity: Major
          Found in lib/hets/dg/node_evaluator.rb and 1 other location - About 1 hr to fix
          lib/hets/dg/node_evaluator.rb on lines 102..123

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

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

            def determine_image_type(resource)
              if resource.is_a?(Repository) && resource.is_private
                return ['data-type', "Private#{resource.class.to_s}"]
              end
          
          
          Severity: Minor
          Found in app/helpers/link_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 pre_axiom has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def pre_axiom(hash)
                if is_annotation_sentence?(hash)
                  m = hash['text'].match(%r{
                    Class:\s+(?<symbol_name>.+?) # Symbol Identifier
                    \s+
          Severity: Minor
          Found in lib/parsing_callback/owl.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 points_through_file? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def points_through_file?(target_path)
              return false if empty?
              return false unless target_path
          
              parts = target_path.split('/')
          Severity: Minor
          Found in lib/git_repository/committing.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 create_symbol_tree has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def create_symbol_tree
                raise StandardError.new('Ontology is not OWL') unless owl?
          
                # Delete previous set of categories
                delete_edges
          Severity: Minor
          Found in app/models/ontology/symbols.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 procure_ontology has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def procure_ontology(element, iri)
                  if element['reference'] == 'true'
                    ontology = Ontology.find_with_iri(iri)
                    if ontology.nil?
                      ontology = ExternalRepository.create_ontology(iri)
          Severity: Minor
          Found in lib/hets/dg/node_evaluation_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 validate_each has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate_each(record, attribute, value)
                bad_uris = []
                if value.is_a?(Array)
                  value.each do |elem|
                    if elem.is_a?(String)
          Severity: Minor
          Found in lib/settings_validation_wrapper/validators.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 resource_chain has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def resource_chain
              return @resource_chain if @resource_chain
          
              if params[:logic_id]
                @resource_chain = []
          Severity: Minor
          Found in app/helpers/application_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 context_pane has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def context_pane
              if params[:controller] == 'home'
                'shared/user_repositories'
              elsif params[:controller] == 'categories' && params[:action] == 'show'
                'shared/user_ontologies'
          Severity: Minor
          Found in app/helpers/application_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 index has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def index
              ontology = Ontology.find params[:ontology_id]
          
              if ontology && (ontology.is?('OWL2') || ontology.is?('OWL'))
                begin
          Severity: Minor
          Found in app/controllers/symbols_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 update_or_create_from_hash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def update_or_create_from_hash(hash, timestamp = Time.now)
                  raise ArgumentError, 'No hash given.' unless hash.is_a? Hash
          
                  e = where(text: hash['text']).first_or_initialize
          
          
          Severity: Minor
          Found in app/models/ontology/symbols.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 fancy_link has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def fancy_link(resource)
              return nil unless resource
          
              data_type, value = determine_image_type(resource)
          
          
          Severity: Minor
          Found in app/helpers/link_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 index has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def index
              ontology = Ontology.find params[:ontology_id]
          
              if ontology && (ontology.is?('OWL2') || ontology.is?('OWL'))
                begin
          Severity: Minor
          Found in app/controllers/symbols_controller.rb - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language