ontohub/ontohub-backend

View on GitHub

Showing 10 of 71 total issues

Method valid? has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

  def valid?
    return @errors.blank? if @validated
    files.each_with_index do |file, index|
      prefix = "files/#{index}/"

Severity: Minor
Found in app/models/multi_blob.rb - About 1 day 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 valid? has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def valid?
    return @errors.blank? if @validated
    files.each_with_index do |file, index|
      prefix = "files/#{index}/"

Severity: Major
Found in app/models/multi_blob.rb - About 3 hrs to fix

    Method get has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.get(scope)
        # rubocop:enable Metrics/AbcSize
        # rubocop:enable Metrics/MethodLength
        # Instead of
        # implements Types::LocIdBaseType, inherit: true
    Severity: Minor
    Found in app/graphql/types/sentence_methods.rb - About 1 hr to fix

      Method normalize_params has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def normalize_params
          files.map! do |file|
            case file[:action].to_sym
            when :create
              {path: file[:path],
      Severity: Minor
      Found in app/models/multi_blob.rb - About 1 hr to fix

        Method instrument has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def instrument(_type, field)
              # rubocop:enable Metrics/MethodLength
              # rubocop:enable Metrics/AbcSize
              old_resolve = field.resolve_proc
              field.redefine do
        Severity: Minor
        Found in app/graphql/instrumenters/validation_error_instrumenter.rb - About 1 hr to fix

          Method instrument has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def instrument(_type, field)
                # rubocop:enable Metrics/MethodLength
                # rubocop:enable Metrics/AbcSize
                old_resolve = field.resolve_proc
                field.redefine do
          Severity: Minor
          Found in app/graphql/instrumenters/validation_error_instrumenter.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 popen has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.popen(cmd, path = nil, vars = {})
              # rubocop:enable Metrics/AbcSize
              # rubocop:enable Metrics/MethodLength
              unless cmd.is_a?(Array)
                raise 'System commands must be given as an array of strings'
          Severity: Minor
          Found in lib/popen.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

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

            def write?
              # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
              return false if resource.nil?
              owner = resource.owner
              return false if resource.remote_type == 'mirror'
          Severity: Minor
          Found in app/policies/repository_policy.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

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

            def save
              normalize_params
              raise ValidationFailed, errors: @errors unless valid?
              self.commit_sha =
                begin
          Severity: Minor
          Found in app/models/multi_blob.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

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

            def process
              return if Document.where(file_version_id: file_version.id).empty?
              previous_revision = find_previous_revision
              return if previous_revision.nil?
          
          
          Severity: Minor
          Found in lib/importing_documents_reanalyzer.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

          Severity
          Category
          Status
          Source
          Language