mysociety/alaveteli

View on GitHub

Showing 90 of 433 total issues

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

  def request_updates_params
    { # Website
      verb_on_page: _("Follow this request"),
      verb_on_page_already: _("You are already following this request"),
      # Email
Severity: Major
Found in app/models/track_thing.rb and 1 other location - About 1 hr to fix
app/models/track_thing.rb on lines 254..272

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

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

  def user_updates_params
    { # Website
      verb_on_page: _("Follow this person"),
      verb_on_page_already: _("You are already following this person"),
      # Email
Severity: Major
Found in app/models/track_thing.rb and 1 other location - About 1 hr to fix
app/models/track_thing.rb on lines 170..188

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

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 3 locations. Consider refactoring.
Open

  module ToDoList
    class VeryOverdueRequest < Item
      def description
        n_("{{count}} request is long overdue.",
           "{{count}} requests are long overdue.",
Severity: Major
Found in app/models/alaveteli_pro/to_do_list/very_overdue_request.rb and 2 other locations - About 55 mins to fix
app/models/alaveteli_pro/to_do_list/new_response.rb on lines 2..31
app/models/alaveteli_pro/to_do_list/overdue_request.rb on lines 2..31

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

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 3 locations. Consider refactoring.
Open

  module ToDoList
    class NewResponse < Item
      def description
        n_("{{count}} request has received a response.",
           "{{count}} requests have received a response.",
Severity: Major
Found in app/models/alaveteli_pro/to_do_list/new_response.rb and 2 other locations - About 55 mins to fix
app/models/alaveteli_pro/to_do_list/overdue_request.rb on lines 2..31
app/models/alaveteli_pro/to_do_list/very_overdue_request.rb on lines 2..31

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

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 3 locations. Consider refactoring.
Open

  module ToDoList
    class OverdueRequest < Item
      def description
        n_("{{count}} request is delayed.",
           "{{count}} requests are delayed.",
Severity: Major
Found in app/models/alaveteli_pro/to_do_list/overdue_request.rb and 2 other locations - About 55 mins to fix
app/models/alaveteli_pro/to_do_list/new_response.rb on lines 2..31
app/models/alaveteli_pro/to_do_list/very_overdue_request.rb on lines 2..31

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

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 to_admin_message has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def to_admin_message(name, email, subject, message, logged_in_user, last_request, last_body)
Severity: Major
Found in app/mailers/contact_mailer.rb - About 50 mins to fix

    Avoid deeply nested control flow statements.
    Open

                raise "dry run mismatched real run" if !errors.empty?
    Severity: Major
    Found in app/controllers/admin_public_body_controller.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

              rescue
                $stderr.puts("Error processing zip file: #{$ERROR_INFO.inspect}")
      Severity: Major
      Found in lib/mail_handler.rb - About 45 mins to fix

        Consider simplifying this complex logical expression.
        Open

              elsif curr_state && (event.event_type == 'followup_sent' || event.event_type == 'sent') && event.described_state && (event.described_state == 'waiting_response' || event.described_state == 'internal_review')
                # Followups can set the status to waiting response / internal
                # review. Initial requests ('sent') set the status to waiting response.
        
                # We want to store that in calculated_state state so it gets
        Severity: Major
        Found in app/models/info_request.rb - About 40 mins to fix

          Avoid too many return statements within this method.
          Open

              return 2 if MailHandler::ReplyHandler.is_oof?(message)
          Severity: Major
          Found in script/handle-mail-replies.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return false if empty_return_path?
            Severity: Major
            Found in app/models/raw_email.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return true
              Severity: Major
              Found in app/models/info_request_event.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    return 0
                Severity: Major
                Found in script/handle-mail-replies.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                      return false if auto_submitted?
                  Severity: Major
                  Found in app/models/raw_email.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          redirect_to frontpage_path and return
                    Severity: Major
                    Found in app/controllers/request_controller.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                            return
                      Severity: Major
                      Found in app/controllers/user_controller.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                              handle_spam_subject(@info_request.user) && return
                        Severity: Major
                        Found in app/controllers/request_controller.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                  return
                          Severity: Major
                          Found in app/controllers/request_controller.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                  return
                            Severity: Major
                            Found in app/controllers/request_controller.rb - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                    return
                              Severity: Major
                              Found in app/controllers/request_controller.rb - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language