testmycode/tmc-server

View on GitHub
app/controllers/application_controller.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method respond_with_error has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def respond_with_error(msg, code = 500, exception = nil, extra_json_keys = {})
      respond_to do |format|
        format.html do
          render 'shared/respond_with_error',
                 locals: { message: ERB::Util.html_escape(msg), exception: exception },
Severity: Minor
Found in app/controllers/application_controller.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

Class ApplicationController has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class ApplicationController < ActionController::Base
  include BreadCrumbs

  helper :all

Severity: Minor
Found in app/controllers/application_controller.rb - About 2 hrs to fix

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

        def check_client_version(client_name, client_version)
          begin
            client_version = Version.new(client_version) unless client_version.nil?
          rescue StandardError
            raise "Invalid version string: #{client_version}"
    Severity: Minor
    Found in app/controllers/application_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 check_api_version has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_api_version
          if should_check_api_version?
            if params[:api_version].blank?
              return respond_with_error('Please update the TMC client. No API version received from client.', 404, nil, obsolete_client: true)
            elsif params[:api_version].to_s != ApiVersion::API_VERSION.to_s
    Severity: Minor
    Found in app/controllers/application_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

    There are no issues that match your filters.

    Category
    Status