Showing 55 of 93 total issues

File entities.rb has 464 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "api/helpers"

module API
  # Entities is a module that groups all the classes to be used as Grape
  # entities.
Severity: Minor
Found in lib/api/entities.rb - About 7 hrs to fix

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

    class User < ApplicationRecord
      include PublicActivity::Common
    
      enum ldap_status: { unchecked: 0, checked: 1, disabled: 2 }
    
    
    Severity: Minor
    Found in app/models/user.rb - About 3 hrs to fix

      File teams.rb has 270 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module API
        module V1
          class Teams < Grape::API
            include PaginationParams
            include OrderingParams
      Severity: Minor
      Found in lib/api/v1/teams.rb - About 2 hrs to fix

        Method get_repo_link_tag has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_repo_link_tag(activity)
            tr = activity.trackable
        
            if tr.nil? || tr.is_a?(Registry)
              if repo_name(activity).nil?
        Severity: Minor
        Found in app/helpers/repositories_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 execute! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def execute!
                digests = []
        
                Tag.where(scanned: Tag.statuses[:scan_none]).find_each do |tag|
                  # This may happen when pushing multiple images with the same digest at
        Severity: Minor
        Found in lib/portus/background/security_scanning.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 ready has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.ready
                server = APP_CONFIG["security"]["clair"]["server"]
                return [nil, false] if server.blank?
        
                uri = URI.join(health_endpoint(server), "/health")
        Severity: Minor
        Found in lib/portus/health_checks/clair.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 find_group has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def find_group(name)
                return [] if APP_CONFIG.disabled?("ldap")
        
                connection = initialized_adapter
                options    = search_options_for(filter: "(cn=#{name})", attributes: %w[member uniqueMember])
        Severity: Minor
        Found in lib/portus/ldap/search.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 layer_vulnerabilities has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def layer_vulnerabilities(digest)
                layer = fetch_layer(digest)
                return [] if layer.nil?
        
                res = []
        Severity: Minor
        Found in lib/portus/security_backends/clair.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 check_account has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def check_account(account)
                if account == "portus"
                  @reason = "Portus user does not go through LDAP"
                  false
                elsif @username.present?
        Severity: Minor
        Found in lib/portus/ldap/configuration.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 ldap_add_as_member! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def ldap_add_as_member!
            Rails.logger.tagged(:ldap) do
              Rails.logger.info "Looking up an LDAP group membership for '#{username}'"
            end
        
        
        Severity: Minor
        Found in app/models/user.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 create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            @user = User.create(user_create_params)
        
            respond_to do |format|
              if @user.persisted?
        Severity: Minor
        Found in app/controllers/admin/users_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 guess_email has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def guess_email(connection, configuration)
                cfg = APP_CONFIG["ldap"]["guess_email"]
                return if cfg.nil? || !cfg["enabled"]
        
                record = search_admin_or_user(connection, configuration)
        Severity: Minor
        Found in lib/portus/ldap/login.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 github_member? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def github_member?(conf)
            if conf["team"].present?
              # Get user's teams.
              is_member = member_of("https://api.github.com/user/teams") do |t|
                t["name"] == conf["team"] &&
        Severity: Minor
        Found in app/controllers/auth/omniauth_callbacks_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 create_users! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def create_users!
              logins = Set.new
        
              while logins.size < NUSERS
                first_name  = FFaker::Name.first_name
        Severity: Minor
        Found in bin/generate_test_data.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 check_membership has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def check_membership
            conf = APP_CONFIG["oauth"][action_name]
        
            case action_name
            when "github"
        Severity: Minor
        Found in app/controllers/auth/omniauth_callbacks_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 authenticate! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def authenticate!
                fill_user_params!
        
                cfg = ::Portus::LDAP::Configuration.new(params)
                if cfg.enabled?
        Severity: Minor
        Found in lib/portus/ldap/authenticatable.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 ready has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.ready
                if APP_CONFIG.enabled?("ldap")
                  ldap = initialized_adapter
                  ldap.bind ? ["LDAP server is reachable", true] : [error_message(ldap), false]
                else
        Severity: Minor
        Found in lib/portus/health_checks/ldap.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 render_repository_information has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def render_repository_information(repository)
            user = current_user
        
            content_tag(:ul) do
              concat content_tag(:li, "You can push images") if can_push?(repository.namespace, user)
        Severity: Minor
        Found in app/helpers/repositories_helper.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 change_description has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def change_description(object, symbol, old_description, new_description, activity_params)
        Severity: Minor
        Found in app/services/helpers/change_name_description.rb - About 35 mins to fix

          Method create_activity has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def create_activity(object, symbol, old_value, new_value, activity_params)
          Severity: Minor
          Found in app/services/helpers/change_name_description.rb - About 35 mins to fix
            Severity
            Category
            Status
            Source
            Language