Showing 167 of 167 total issues

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

  it('should be logged in if token exists in local storage and not Expired',
     () => {
       mockLocalStorage.setItem('auth_token', mockTokenNotExpired);
       expect(authService.isLoggedIn()).toBe(true);
     });
Severity: Minor
Found in web/app/services/auth.service.spec.ts and 1 other location - About 35 mins to fix
web/app/services/auth.service.spec.ts on lines 75..78

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 47.

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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def call(env)
      unless Faye::WebSocket.websocket?(env)
        # This is a regular HTTP call (no socket connection)
        # so just redirect to the user's app
        return @app.call(env)
Severity: Minor
Found in app/features/build/build_websocket_backend.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 update_all_open_prs_without_status_to_pending_status! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def update_all_open_prs_without_status_to_pending_status!(repo_full_name: nil, status_context: nil)
      open_pr_commits = open_pull_requests(repo_full_name: repo_full_name)
      updated_commits = []

      open_pr_commits.each do |open_pull_request|
Severity: Minor
Found in app/services/code_hosting/git_hub_service.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def run
      # send logs that get put on the output queue.
      # this needs to be on a separate thread since Queue is a threadsafe blocking queue.
      Thread.new do
        while state == "running"
Severity: Minor
Found in agent/invocation.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 checkout_commit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def checkout_commit(sha: nil, repo_auth: self.repo_auth, use_global_git_mutex: true, completion_block: nil)
      perform_block(use_global_git_mutex: use_global_git_mutex) do
        repo_url = git_config.git_url
        logger.info("Checking out sha: #{sha} from #{repo_url}")
        setup_auth(repo_auth: repo_auth)
Severity: Minor
Found in app/shared/models/git_repo.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 reload_settings has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def reload_settings
      JSONSettingDataSource.file_semaphore.synchronize do
        @settings = AvailableSettings.available_settings

        unless File.exist?(setting_file_path)
Severity: Minor
Found in app/services/data_sources/json_setting_data_source.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 reload_notifications has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def reload_notifications
      JSONNotificationDataSource.file_semaphore.synchronize do
        @notifications =
          if !File.exist?(notifications_file_path)
            notifications_dirname = File.dirname(notifications_file_path)
Severity: Minor
Found in app/services/data_sources/json_notification_data_source.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 fastfile_from_repo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def fastfile_from_repo(repo_config: nil, branch: nil, sha: nil)
      git_repo = FastlaneCI::GitRepo.new(
        git_config: repo_config,
        local_folder: Dir.mktmpdir,
        provider_credential: @provider_credential,
Severity: Minor
Found in app/shared/fastfile_peeker.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 ensure_proper_setup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def ensure_proper_setup(route = nil)
      route = "#{self::HOME}*" if route.nil?

      before(route) do
        if !route.start_with?("/onboarding_erb") && !Services.onboarding_service.correct_setup?
Severity: Minor
Found in app/shared/setup_checker.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
Severity: Major
Found in app/services/configuration_repository_service.rb - About 30 mins to fix

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

          begin
            # Note: This fails if the user.email scope is missing from token
            email = github_client.emails.find(&:primary).email
          rescue Octokit::NotFound
            json_error!(
    Severity: Minor
    Found in app/features-json/repos_json_controller.rb and 1 other location - About 30 mins to fix
    app/features-json/user_json_controller.rb on lines 16..30

    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 32.

    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

        post "#{HOME}/update" do
          if valid_params?(params, post_parameter_list_for_validation)
            environment_variable = EnvironmentVariable.new(
              key: params[:key],
              value: params[:value]
    app/features/users/users_controller.rb on lines 32..42

    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 32.

    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

        def initialize(provider_credential:, project:, notification_service:)
          @trigger_type = FastlaneCI::JobTrigger::TRIGGER_TYPE[:commit]
          @scheduler = WorkerScheduler.new(interval_time: 10)
          @github_service = FastlaneCI::GitHubService.new(provider_credential: provider_credential)
    
    
    Severity: Minor
    Found in app/workers/check_for_new_commits_on_github_worker.rb and 1 other location - About 30 mins to fix
    app/workers/check_for_new_prs_on_github_worker.rb on lines 31..41

    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 32.

    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

        def initialize(provider_credential:, project:, notification_service:)
          @trigger_type = FastlaneCI::JobTrigger::TRIGGER_TYPE[:pull_request]
          @scheduler = WorkerScheduler.new(interval_time: 10)
          @github_service = FastlaneCI::GitHubService.new(provider_credential: provider_credential)
    
    
    Severity: Minor
    Found in app/workers/check_for_new_prs_on_github_worker.rb and 1 other location - About 30 mins to fix
    app/workers/check_for_new_commits_on_github_worker.rb on lines 34..44

    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 32.

    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

        post "#{HOME}/update" do
          if valid_params?(params, post_parameter_list_for_validation)
            updated_user = User.new(
              id: params[:id],
              email: params[:email]
    Severity: Minor
    Found in app/features/users/users_controller.rb and 1 other location - About 30 mins to fix
    app/features/environment_variables/environment_variables_controller.rb on lines 38..50

    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 32.

    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

          begin
            # Note: This fails if the user.email scope is missing from token
            email = github_client.emails.find(&:primary).email
          rescue Octokit::NotFound
            json_error!(
    Severity: Minor
    Found in app/features-json/user_json_controller.rb and 1 other location - About 30 mins to fix
    app/features-json/repos_json_controller.rb on lines 26..40

    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 32.

    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 viewmodel_from! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def viewmodel_from!(object:)
            raise "Override base_model(model) in order to use the ViewModel mixin." if @base_model.nil?
            raise "Incorrect object type. Expected #{@base_model}, got #{object.class}" unless object.kind_of?(@base_model)
            if object.respond_to?(:to_object_dictionary)
              instance_variables = @base_model.instance_variables
    Severity: Minor
    Found in app/features-json/view_models/view_model.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 user_has_valid_github_token? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def user_has_valid_github_token?(provider_credentials: [])
          provider_credentials.each do |provider_credential|
            if provider_credential.type == FastlaneCI::ProviderCredential::PROVIDER_CREDENTIAL_TYPES[:github]
              if provider_credential.api_token.nil?
                return false
    Severity: Minor
    Found in app/features/login/login_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

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

        def retrieve!(artifact:)
          raise "Artifact to store was not provided or wrong type provided" unless artifact&.is_a?(Artifact)
    
          if File.exist?(artifact.reference)
            artifact_reference = artifact.reference
    Severity: Minor
    Found in app/shared/models/local_artifact_provider.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 validate_initialization_params! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_initialization_params!(
          git_config: nil,
          local_folder: nil,
          provider_credential: nil,
          async_start: nil,
    Severity: Minor
    Found in app/shared/models/git_repo.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