gitlabhq/gitlab-ci

View on GitHub

Showing 44 of 58 total issues

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

  def authenticate_public_page!
    unless project.public
      unless current_user
        redirect_to(new_user_sessions_path(state: generate_oauth_state(request.fullpath))) and return
      end
Severity: Minor
Found in app/controllers/application_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

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

  def can_execute?(build)
    return if build.allow_failure?

    commit = build.commit
    return unless commit
Severity: Minor
Found in app/models/project_services/hip_chat_service.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 execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def execute(project, params)
    before_sha = params[:before]
    sha = params[:checkout_sha] || params[:after]
    origin_ref = params[:ref]
    
Severity: Minor
Found in app/services/create_commit_service.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 can_execute? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def can_execute?(build)
    return if build.allow_failure?

    # it doesn't make sense to send emails for retried builds
    commit = build.commit
Severity: Minor
Found in app/models/project_services/mail_service.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 gitlab has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def gitlab
    @limit, @offset = (params[:limit] || PROJECTS_BATCH).to_i, (params[:offset] || 0).to_i
    @page = @offset == 0 ? 1 : (@offset / @limit + 1)

    current_user.reset_cache if params[:reset_cache]
Severity: Minor
Found in app/controllers/projects_controller.rb - About 45 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 status has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def status
    if skip_ci?
      return 'skipped'
    elsif yaml_errors.present?
      return 'failed'
Severity: Minor
Found in app/models/commit.rb - About 45 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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def execute
    puts "GitLab CI #{current_version.major} upgrade tool"
    puts "Your version is #{current_version}"
    puts "Latest available version for GitLab CI #{current_version.major} is #{latest_version}"

Severity: Minor
Found in lib/upgrader.rb - About 45 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 deeply nested control flow statements.
Open

                    if "DEFAULT '0'" in extra:
                        final_default = "FALSE"
                    elif "DEFAULT '1'" in extra:
                        final_default = "TRUE"

Severity: Major
Found in lib/support/mysql-postgresql-converter/db_converter.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if enum_name not in enum_types:
                            output.write("CREATE TYPE {0} AS ENUM ({1}); \n".format(enum_name, types_str));
                            enum_types.append(enum_name)
    
    
    Severity: Major
    Found in lib/support/mysql-postgresql-converter/db_converter.py - About 45 mins to fix

      Method get_xterm_color_class has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_xterm_color_class(command_stack, prefix)
            # the 38 and 48 commands have to be followed by "5" and the color index
            return unless command_stack.length >= 2
            return unless command_stack[0] == "5"
      
      
      Severity: Minor
      Found in lib/ansi2html.rb - About 45 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 initial_parsing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def initial_parsing
          @before_script = @config[:before_script] || []
          @image = @config[:image]
          @services = @config[:services]
          @stages = @config[:stages] || @config[:types]
      Severity: Minor
      Found in lib/gitlab_ci_yaml_processor.rb - About 45 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 deeply nested control flow statements.
      Open

                          if final_default:
                              cast_lines.append("ALTER TABLE \"%s\" ALTER COLUMN \"%s\" SET DEFAULT %s" % (current_table, name, final_default))
                      # ID fields need sequences [if they are integers?]
                      if name == "id" and set_sequence is True:
      Severity: Major
      Found in lib/support/mysql-postgresql-converter/db_converter.py - About 45 mins to fix

        Consider simplifying this complex logical expression.
        Open

                if line.startswith("--") or line.startswith("/*") or line.startswith("LOCK TABLES") or line.startswith("DROP TABLE") or line.startswith("UNLOCK TABLES") or not line:
                    continue
        
                # Outside of anything handling
                if current_table is None:
        Severity: Major
        Found in lib/support/mysql-postgresql-converter/db_converter.py - About 40 mins to fix

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

              def dump(mysql_to_postgresql=false)
                FileUtils.rm_f(db_file_name)
                compress_rd, compress_wr = IO.pipe
                compress_pid = spawn(*%W(gzip -1 -c), in: compress_rd, out: [db_file_name, 'w', 0600])
                compress_rd.close
          Severity: Minor
          Found in lib/backup/database.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 cleanup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def cleanup
                $progress.print "Deleting tmp directories ... "
                
                backup_contents.each do |dir|
                  next unless File.exist?(File.join(GitlabCi.config.backup.path, dir))
          Severity: Minor
          Found in lib/backup/manager.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 runner_status_icon has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def runner_status_icon(runner)
              unless runner.contacted_at
                return content_tag :i, nil,
                  class: "icon-warning-sign",
                  title: "New runner. Has not connected yet"
          Severity: Minor
          Found in app/helpers/runners_helper.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 perform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def perform
              projects = Project.where(always_build: true).all
              projects.each do |project|
                last_commit = project.commits.last
                next unless last_commit && last_commit.last_build
          Severity: Minor
          Found in lib/scheduler.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 false if !tag && except_params.include?("branches")
          Severity: Major
          Found in lib/gitlab_ci_yaml_processor.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return false if match_ref?(pattern, ref)
            Severity: Major
            Found in lib/gitlab_ci_yaml_processor.rb - About 30 mins to fix

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

                def show
                  if params[:id] =~ /\A\d+\Z/
                    @build = build
                  else
                    # try to find commit by sha
              Severity: Minor
              Found in app/controllers/builds_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

              Severity
              Category
              Status
              Source
              Language