mysociety/alaveteli

View on GitHub
app/helpers/link_to_helper.rb

Summary

Maintainability
A
3 hrs
Test Coverage

File link_to_helper.rb has 269 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module LinkToHelper
  # Links to various models

  # Requests
  def request_url(info_request, options = {})
Severity: Minor
Found in app/helpers/link_to_helper.rb - About 2 hrs to fix

    Method do_track_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def do_track_url(track_thing, feed = 'track', options = {})
        if track_thing.track_type == 'request_updates'
          track_request_url(options.merge(url_title: track_thing.info_request.url_title, feed: feed))
        elsif track_thing.track_type == 'all_new_requests'
          track_list_url(options.merge(view: 'recent', feed: feed))
    Severity: Minor
    Found in app/helpers/link_to_helper.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 user_link_for_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def user_link_for_request(request)
        if request.is_external?
          user_name = request.external_user_name || _("Anonymous user")
          if !request.external_url.nil?
            link_to user_name, request.external_url
    Severity: Minor
    Found in app/helpers/link_to_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

    There are no issues that match your filters.

    Category
    Status