Showing 73 of 94 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        context 'when status from SCC is unknown' do
          before do
            stub_request(:get, scc_systems_activations_url).to_return(status: 200, body: [body_unknown_status].to_json, headers: {})
            expect(URI).to receive(:encode_www_form).with({ byos: true })
            allow(File).to receive(:directory?)
engines/zypper_auth/spec/requests/strict_authentication/authentication_controller_spec.rb on lines 176..186

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 55.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method mirror_repositories! has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
Open

  def mirror_repositories!(repos)
    downloaded_files_count = 0
    downloaded_files_size = 0

    repos.compact.each do |repo|
Severity: Minor
Found in lib/rmt/cli/mirror.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      context 'when repo name is not allowed' do
        subject(:access_scope) do
          described_class.new(
            type: 'a',
            name: 'super_expensive/suse/sles/*',
Severity: Major
Found in engines/registry/spec/app/models/access_scope_spec.rb and 1 other location - About 1 hr to fix
engines/registry/spec/app/models/access_scope_spec.rb on lines 178..197

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 55.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        context 'when SCC request fails' do
          before do
            stub_request(:get, scc_systems_activations_url).to_return(status: 401, body: [body_expired].to_json, headers: {})
            expect(URI).to receive(:encode_www_form).with({ byos: true })
            allow(File).to receive(:directory?)
engines/zypper_auth/spec/requests/strict_authentication/authentication_controller_spec.rb on lines 163..173

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 55.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method parse_package_list has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def parse_package_list(packagelist)
    packages = []
    hdl = File.open(packagelist.local_path, 'rb')

    current = {}
Severity: Minor
Found in lib/rmt/mirror/debian.rb - About 1 hr to fix

    Method generate_partial_report has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def generate_partial_report(repo_base_dir, cleaned_files)
        cleaned_files_count = cleaned_files.count
        cleaned_files_size = cleaned_files.sum(&:file_size)
        cleaned_db_entries = cleaned_files.sum(&:db_entries_count)
    
    
    Severity: Minor
    Found in lib/rmt/cli/clean.rb - About 1 hr to fix

      Method packages has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def packages
          print "\n\e[1m"
          print _("Scanning the mirror directory for 'repomd.xml' files...")
          print "\e[0m\n"
      
      
      Severity: Minor
      Found in lib/rmt/cli/clean.rb - About 1 hr to fix

        Method product has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def product(*targets)
            RMT::Lockfile.lock('mirror') do
              start_time = Time.current
        
              targets = clean_target_input(targets)
        Severity: Minor
        Found in lib/rmt/cli/mirror.rb - About 1 hr to fix

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

            def run_package_clean(repomd_files)
              # Initialize table to keep registry of inodes referencing dangling files/links
              @inodes = Hash.new(0)
          
              partial_reports =
          Severity: Minor
          Found in lib/rmt/cli/clean.rb - About 1 hr to fix

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

              def change_product(target, set_enabled, all_modules)
                base_products = fetch_base_product target
            
                base_products.each do |base_product|
                  products = [base_product]
            Severity: Minor
            Found in lib/rmt/cli/products.rb - About 1 hr to fix

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

              def main
                OptionParser.new do |opts|
                  opts.banner += ' [Repositories]'
                  opts.separator 'Get repository CDN tokens'
                  opts.version = '0.0.1'
              Severity: Minor
              Found in contrib/get_repository_tokens.rb - About 1 hr to fix

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                    context 'when the base product subscription is missing' do
                      let(:base_product) { FactoryBot.create(:product, :with_mirrored_repositories) }
                      let(:product) do
                        FactoryBot.create(
                          :product, :with_mirrored_repositories, :extension, free: false, base_products: [base_product]
                engines/scc_proxy/spec/requests/api/connect/v3/systems/products_controller_spec.rb on lines 295..306

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 45.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Method create_product_activation has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
                Open

                  def create_product_activation
                    activation = @system.activations.where(service_id: @product.service.id).first_or_create
                
                    # in BYOS mode, we rely on the activation being performed in
                    # `engines/scc_proxy/lib/scc_proxy/engine.rb` and don't need further checks here
                Severity: Minor
                Found in app/controllers/api/connect/v3/systems/products_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 scc_deactivate_product has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
                Open

                        def scc_deactivate_product
                          auth = request.headers['HTTP_AUTHORIZATION']
                          if @system.proxy_byos && @product[:product_type] != 'base'
                            response = SccProxy.deactivate_product_scc(auth, @product, @system.system_token)
                            unless response.code_type == Net::HTTPOK
                Severity: Minor
                Found in engines/scc_proxy/lib/scc_proxy/engine.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

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                    context 'when the base product subscription is missing' do
                      let(:base_product) { FactoryBot.create(:product, :with_mirrored_repositories) }
                      let(:product) do
                        FactoryBot.create(
                          :product, :with_mirrored_repositories, :extension, free: false, base_products: [base_product]
                engines/instance_verification/spec/requests/api/connect/v3/systems/products_controller_spec.rb on lines 205..216

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 45.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                          before do
                            headers['X-Instance-Data'] = 'IMDS'
                            allow_any_instance_of(InstanceVerification::Providers::Example).to(
                              receive(:instance_valid?).and_return(true)
                            )
                engines/strict_authentication/spec/requests/services_controller_spec.rb on lines 75..85

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 44.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                      before do
                        headers['X-Instance-Data'] = 'IMDS'
                        allow_any_instance_of(InstanceVerification::Providers::Example).to(
                          receive(:instance_valid?).and_return(true)
                        )
                engines/strict_authentication/spec/requests/services_controller_spec.rb on lines 56..66

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 44.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Method verify_product_activation has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
                Open

                        def verify_product_activation
                          product = find_product
                
                          if product.base?
                            verify_base_product_activation(product)
                Severity: Minor
                Found in engines/instance_verification/lib/instance_verification/engine.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

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                    context 'when the extension is free' do
                      let(:base_product) { FactoryBot.create(:product, :with_mirrored_repositories) }
                      let(:product) do
                        FactoryBot.create(
                          :product, :with_mirrored_repositories, :extension, free: true, base_products: [base_product]
                engines/instance_verification/spec/requests/api/connect/v3/systems/products_controller_spec.rb on lines 190..200

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 40.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        context 'when subscription is expired' do
                          before do
                            stub_request(:get, scc_systems_activations_url).to_return(status: 200, body: [body_expired].to_json, headers: {})
                            expect(URI).to receive(:encode_www_form).with({ byos: true })
                            get '/api/auth/check', headers: headers
                engines/zypper_auth/spec/requests/strict_authentication/authentication_controller_spec.rb on lines 153..160

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 40.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Severity
                Category
                Status
                Source
                Language