chef/supermarket

View on GitHub

Showing 27 of 49 total issues

File schema.rb has 380 lines of code (exceeds 250 allowed). Consider refactoring.
Open

ActiveRecord::Schema.define(version: 20200629195534) do

  # These are extensions that must be enabled in order to support this database
  enable_extension "plpgsql"
  enable_extension "pg_trgm"
Severity: Minor
Found in src/supermarket/db/schema.rb - About 5 hrs to fix

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

      def follow_button_for(cookbook, params = {}, &block)
        fa_icon = tag.i("", class: "fa fa-users")
        followers_count = cookbook.cookbook_followers_count.to_s
        followers_count_span = tag.span(
          number_with_delimiter(followers_count),
    Severity: Major
    Found in src/supermarket/app/helpers/cookbooks_helper.rb - About 2 hrs to fix

      Class QualityMetricsController has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Api::V1::QualityMetricsController < Api::V1Controller
        before_action :check_cookbook_name_present, except: :license_evaluation
        before_action :check_authorization, except: :license_evaluation
        before_action :find_cookbook_version, except: :license_evaluation
      
      
      Severity: Minor
      Found in src/supermarket/app/controllers/api/v1/quality_metrics_controller.rb - About 2 hrs to fix

        Method follow_button_for has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

          def follow_button_for(cookbook, params = {}, &block)
            fa_icon = tag.i("", class: "fa fa-users")
            followers_count = cookbook.cookbook_followers_count.to_s
            followers_count_span = tag.span(
              number_with_delimiter(followers_count),
        Severity: Minor
        Found in src/supermarket/app/helpers/cookbooks_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 publish_version! has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def publish_version!(params, user)
            metadata = params.metadata
        
            if metadata.privacy &&
               ENV["ENFORCE_PRIVACY"].present? &&
        Severity: Minor
        Found in src/supermarket/app/models/cookbook.rb - About 1 hr to fix

          Method show has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def show
                redis_health = { status: REACHABLE }
                sidekiq_health = { status: REACHABLE }
          
                begin

            Method authenticate_user! has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def authenticate_user!
                username = request.headers["X-Ops-Userid"]
                user = Account.for("chef_oauth2").where(username: username).first.try(:user)
            
                unless user

              Method each_entry has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def each_entry
                    raise NoPath unless @source.respond_to?(:path)
                    raise NotGzipped unless gzipped?
              
                    begin
              Severity: Minor
              Found in src/supermarket/app/models/cookbook_upload/archive.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 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                def create
                  if group_member_params[:user_ids].present?
                    user_ids = group_member_params[:user_ids].split(",")
                  else
                    flash[:warning] = "At least one user must be added!"
              Severity: Minor
              Found in src/supermarket/app/controllers/group_members_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 generate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def generate(opts = {})
                  #
                  # So yeah, why are we using SQL here instead of our friend ActiveRecord?
                  # Turns out, when you're retrieving a lot of objects at once, and joining
                  # objects on foreign keys, AR is really slow - prohibitively slow for what
              Severity: Minor
              Found in src/supermarket/app/models/universe.rb - About 1 hr to fix

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

                  def versions_string(versions)
                    versions_string = ""
                
                    if versions.first.class == Array
                      versions.each do |version_set|
                Severity: Minor
                Found in src/supermarket/app/helpers/cookbook_versions_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 perform has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def perform(account_id)
                    account = Account.find(account_id)
                
                    strategy = OmniAuth::Strategies::ChefOAuth2.new(
                      Rails.application,
                Severity: Minor
                Found in src/supermarket/app/workers/oauth_token_refresh_worker.rb - About 1 hr to fix

                  Method create has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def create
                      if group_member_params[:user_ids].present?
                        user_ids = group_member_params[:user_ids].split(",")
                      else
                        flash[:warning] = "At least one user must be added!"
                  Severity: Minor
                  Found in src/supermarket/app/controllers/group_members_controller.rb - About 1 hr to fix

                    Method create has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def create
                        cookbook_upload = CookbookUpload.new(current_user, upload_params)
                    
                        begin
                          authorize! cookbook_upload.cookbook

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

                        def create
                          cookbook_upload = CookbookUpload.new(current_user, upload_params)
                      
                          begin
                            authorize! cookbook_upload.cookbook
                      Severity: Minor
                      Found in src/supermarket/app/controllers/api/v1/cookbook_uploads_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 update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def update
                          @user = current_user
                      
                          authorize! @tool
                      
                      
                      Severity: Minor
                      Found in src/supermarket/app/controllers/tools_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 perform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def perform(account_id)
                          account = Account.find(account_id)
                      
                          strategy = OmniAuth::Strategies::ChefOAuth2.new(
                            Rails.application,
                      Severity: Minor
                      Found in src/supermarket/app/workers/oauth_token_refresh_worker.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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def update
                          authorize! @cookbook, :manage_cookbook_urls?
                      
                          @cookbook.update(cookbook_urls_params)
                      
                      
                      Severity: Minor
                      Found in src/supermarket/app/controllers/cookbooks_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 perform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def perform(cookbook_json, cookbook_name)
                          parsed = JSON.parse(cookbook_json)
                      
                          failure = false
                          publish_feedback = ""
                      Severity: Minor
                      Found in src/supermarket/engines/fieri/app/models/publish_worker.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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def create
                          if %w{Cookbook Tool}.include?(collaborator_params[:resourceable_type])
                            resource = collaborator_params[:resourceable_type].constantize.find(
                              collaborator_params[:resourceable_id]
                            )
                      Severity: Minor
                      Found in src/supermarket/app/controllers/collaborators_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

                      Severity
                      Category
                      Status
                      Source
                      Language