talho/openphin

View on GitHub
app/controllers/audits_controller.rb

Summary

Maintainability
D
2 days
Test Coverage

Method get_version has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

  def get_version(id)
    if allowed_to_see(id)
      req_ver = Version.find(id)
      req_rec = reify_and_get_attrs(req_ver)
      req_rec = req_ver.item_type.constantize.new.attributes if req_rec.nil?
Severity: Minor
Found in app/controllers/audits_controller.rb - About 7 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

Method sanitize_and_beautify_for_your_comfort has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def sanitize_and_beautify_for_your_comfort(version_attributes)
    # strip the data, but still report as changed.
    hidden_attributes = ['encrypted_password', 'salt', 'token', 'phin_oid', 'confirmation_token']
    date_attributes = ['created_at', 'updated_at', 'file_updated_at']
    lookup_attributes = {'alert_id' => Alert, 'alert_attempt_id' => AlertAttempt, 'approver_id' => User, 'audience_id' => Audience, 'author_id' => User,
Severity: Minor
Found in app/controllers/audits_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

Method get_version_list has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def get_version_list(params)
    # set some defaults
    params[:start] = 0 unless params[:start]
    params[:limit] =  30 unless params[:limit]
    params[:sort] = 'id' unless params[:sort]
Severity: Minor
Found in app/controllers/audits_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

Method get_version has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def get_version(id)
    if allowed_to_see(id)
      req_ver = Version.find(id)
      req_rec = reify_and_get_attrs(req_ver)
      req_rec = req_ver.item_type.constantize.new.attributes if req_rec.nil?
Severity: Minor
Found in app/controllers/audits_controller.rb - About 1 hr to fix

    Method show has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def show
        if allowed_to_see(params['id'])
          versions = {}
          versions['requested_version'] = get_version(params['id']) unless Version.find(params['id']).nil?
          versions['next_version']      = get_version(Version.find(params['id']).next.id) unless Version.find(params['id']).next.nil?
    Severity: Minor
    Found in app/controllers/audits_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 get_version_list has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def get_version_list(params)
        # set some defaults
        params[:start] = 0 unless params[:start]
        params[:limit] =  30 unless params[:limit]
        params[:sort] = 'id' unless params[:sort]
    Severity: Minor
    Found in app/controllers/audits_controller.rb - About 1 hr to fix

      There are no issues that match your filters.

      Category
      Status