codeclimate/ruby-test-reporter

View on GitHub

Showing 5 of 25 total issues

Method service_data has 96 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.service_data(env = ENV)
        if env["TRAVIS"]
          {
            name:             "travis-ci",
            branch:           env["TRAVIS_BRANCH"],
Severity: Major
Found in lib/code_climate/test_reporter/ci.rb - About 3 hrs to fix

    Method service_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.service_data(env = ENV)
            if env["TRAVIS"]
              {
                name:             "travis-ci",
                branch:           env["TRAVIS_BRANCH"],
    Severity: Minor
    Found in lib/code_climate/test_reporter/ci.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 to_payload has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def to_payload(result)
            totals = Hash.new(0)
            source_files = result.files.map do |file|
              totals[:total] += file.lines.count
              totals[:covered] += file.covered_lines.count
    Severity: Minor
    Found in lib/code_climate/test_reporter/formatter.rb - About 1 hr to fix

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

            def validate
              raise InvalidPayload, "A git commit sha was not found in the test report payload" unless commit_sha
              raise InvalidPayload, "A git commit timestamp was not found in the test report payload" unless committed_at
              raise InvalidPayload, "A run at timestamp was not found in the test report payload" unless run_at
              raise InvalidPayload, "No source files were found in the test report payload" unless source_files?
      Severity: Minor
      Found in lib/code_climate/test_reporter/payload_validator.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 batch_post_results has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def batch_post_results(files)
              uri = URI.parse("#{host}/test_reports/batch")
              http = http_client(uri)
      
              boundary = SecureRandom.uuid
      Severity: Minor
      Found in lib/code_climate/test_reporter/client.rb - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language