ontohub/ontohub

View on GitHub

Showing 95 of 107 total issues

Method commits_path has a Cognitive Complexity of 34 (exceeds 5 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 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 list has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

  def list()
    type_iri = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
    label_iri = 'http://www.w3.org/2000/01/rdf-schema#label'
    comment_iri = 'http://www.w3.org/2000/01/rdf-schema#comment'
    defined_iri = 'http://www.w3.org/2000/01/rdf-schema#isDefinedBy'
Severity: Minor
Found in lib/logic_mapping_population.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

Method initialize has 106 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize(user, access_token)
    # Define abilities for the passed in user here.

    user ||= User.new # guest user (not logged in)

Severity: Major
Found in app/models/ability.rb - About 4 hrs to fix

    Class Ontology has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Ontology < LocIdBaseModel
      # Ontohub Library Includes
      include Commentable
      include Metadatable
    
    
    Severity: Minor
    Found in app/models/ontology.rb - About 3 hrs to fix

      Class RepositoryFile has 28 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class RepositoryFile < FakeRecord
        class PathValidator < ActiveModel::Validator
          def validate(record)
            if record.repository.points_through_file?(record.target_path)
              record.errors[:target_directory] = "Error! This path points to or through a file."
      Severity: Minor
      Found in app/fake_records/repository_file.rb - About 3 hrs to fix

        Class GitRepository has 27 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class GitRepository
          require 'git_repository/config'
        
          include GitRepository::Config
          include GitRepository::Cloning
        Severity: Minor
        Found in lib/git_repository.rb - About 3 hrs to fix

          Method start_element has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              def start_element(name, attributes)
                @path << name
                case name
                  when ROOT
                    callback(:root, Hash[*[attributes]])
          Severity: Minor
          Found in lib/logicgraph_parser.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 list has 68 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def list()
              type_iri = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
              label_iri = 'http://www.w3.org/2000/01/rdf-schema#label'
              comment_iri = 'http://www.w3.org/2000/01/rdf-schema#comment'
              defined_iri = 'http://www.w3.org/2000/01/rdf-schema#isDefinedBy'
          Severity: Major
          Found in lib/logic_mapping_population.rb - About 2 hrs to fix

            Method initialize has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

              def initialize(user, access_token)
                # Define abilities for the passed in user here.
            
                user ||= User.new # guest user (not logged in)
            
            
            Severity: Minor
            Found in app/models/ability.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 permission? has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

              def permission?(role, user)
                # Deny if user is nil
                return false unless user
            
                # Deny if user is of wrong type
            Severity: Minor
            Found in lib/permissionable.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 start_element has 59 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: Major
            Found in lib/logicgraph_parser.rb - About 2 hrs to fix

              Method ontology_nav has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def ontology_nav(ontology, current_page)
                  resource = resource_chain.last
              
                  content_page = ontology.distributed? ? :children : :symbols
                  @top_level_pages = [
              Severity: Major
              Found in app/helpers/navigation_helper.rb - About 2 hrs to fix

                Method end_element has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    def end_element(name)
                      @path.pop
                
                      case name
                      when ONTOLOGY
                Severity: Minor
                Found in lib/ontology_parser.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 end_element has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                      def end_element(name)
                        order = :end
                        @path.pop
                
                        case name
                Severity: Minor
                Found in lib/hets/dg/nokogiri_listener.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 fancy_tag has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                  def fancy_tag(resource, tags)
                    result = ""
                    first = true
                    tags.each do |tag|
                      if (eval "resource." + tag.to_s)
                Severity: Minor
                Found in app/helpers/tag_helper.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 initialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                  def initialize(collection_path, options)
                    @collection_path = collection_path
                    @editable        = true
                
                    options.each do |key,value|
                Severity: Minor
                Found in lib/relation_list.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 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def update_or_create_from_hash(hash, _user, timestamp = Time.now)
                        raise ArgumentError, 'No hash given.' unless hash.is_a? Hash
                        # hash['name'] # maybe nil, in this case, we need to generate a name
                        mapping_iri   = locid_for_child(hash['name'] || hash['linkid'])
                        mapping_name  = hash['name']
                Severity: Minor
                Found in app/models/ontology/mappings.rb - About 1 hr to fix

                  Method commits_all has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def commits_all(walker, limit, offset, &block)
                      commits = []
                      original_offset = offset
                  
                      walker.each_with_index do |c,i|
                  Severity: Minor
                  Found in lib/git_repository/history.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 start_element has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def start_element(name, attributes)
                          order = :start
                          @path << name
                          case name
                          when ROOT
                  Severity: Minor
                  Found in lib/hets/dg/nokogiri_listener.rb - About 1 hr to fix

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

                          def end_element(name)
                            order = :end
                            @path.pop
                    
                            case name
                    Severity: Minor
                    Found in lib/hets/dg/nokogiri_listener.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language