pivotal/projectmonitor

View on GitHub

Showing 31 of 31 total issues

Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def initialize(stdin, stdout, org, space, env, cf_authenticator = CF_authenticator.new(), cf_git_tagger = CF_git_tagger.new())
Severity: Major
Found in lib/cf_deploy.rb - About 50 mins to fix

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

      var showAuthTokenError = function () {
        $('#project_tracker_auth_token_status .failure').removeClass('hide');
        $('#tracker_status .failure').removeClass('hide').text("Error in auth token");
      };
    Severity: Minor
    Found in app/assets/javascripts/projectEdit.js and 1 other location - About 45 mins to fix
    app/assets/javascripts/projectEdit.js on lines 14..17

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

    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

      var showProjectIdError = function () {
        $('#project_tracker_project_id_status .failure').removeClass('hide');
        $('#tracker_status .failure').removeClass('hide').text("Error in project ID");
      };
    Severity: Minor
    Found in app/assets/javascripts/projectEdit.js and 1 other location - About 45 mins to fix
    app/assets/javascripts/projectEdit.js on lines 9..12

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

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

        def import(config)
          config = YAML.load(config)
    
          Project.transaction do
            cached_agg = {}
    Severity: Minor
    Found in lib/config_export.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

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

        else if ($('input#project_webhooks_enabled_false:checked').length > 0) {
          $('#field_container').removeClass('hide');
          $('#webhook_url').addClass('hide');
          $('fieldset#polling').removeClass('hide');
        }
    Severity: Minor
    Found in app/assets/javascripts/projectEdit.js and 1 other location - About 40 mins to fix
    app/assets/javascripts/projectEdit.js on lines 200..209

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

    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

            if (result.status) {
              $('#polling .pending').addClass('hide');
              $('#build_status .success').removeClass('hide');
              $('.error-message').addClass('hide');
            }
    Severity: Minor
    Found in app/assets/javascripts/projectEdit.js and 1 other location - About 40 mins to fix
    app/assets/javascripts/projectEdit.js on lines 238..242

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

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

      def convert_xml_content!(raw_content, preserve_case = false)
        raw_content = raw_content.downcase unless preserve_case
        parsed_xml = Nokogiri::XML.parse(raw_content)
        raise Payload::InvalidContentException, "Error converting content for project #{@project_name}" unless parsed_xml.root
        parsed_xml
    Severity: Minor
    Found in lib/payload.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 fetch_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def fetch_status(project, url)
        @concourse_authenticator.authenticate(project.auth_url, project.auth_username, project.auth_password) do |auth_poll_state, auth_status_code, auth_response|
          if auth_poll_state != PollState::SUCCEEDED
            yield auth_poll_state, auth_response, auth_status_code
          else
    Severity: Minor
    Found in lib/concourse_project_strategy.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        if project = Project.find_by_guid(params.delete(:project_id))
          payload = project.webhook_payload
          payload.remote_addr = request.env['REMOTE_ADDR']
    
    
    Severity: Minor
    Found in app/controllers/status_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 add_statuses_from_payload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def add_statuses_from_payload
        payload.each_status do |status|
          next if project.has_status?(status)
          if status.valid?
            @status_updater.update_project(project, status)
    Severity: Minor
    Found in lib/payload_processor.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 project_last_status_text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def project_last_status_text(project)
        if latest = project.latest_payload_log_entry
          if project.enabled
            latest.status || 'Unknown Status'
          else
    Severity: Minor
    Found in app/helpers/projects_helper.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