robertgauld/OSMExtender

View on GitHub

Showing 203 of 203 total issues

Avoid too many return statements within this method.
Open

    return ordinalized_date(time, '%H:%M on %-d %B %Y')
Severity: Major
Found in app/helpers/application_helper.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return {success: false, errors: ['Could not retrieve Staged badges from OSM.']}
    Severity: Major
    Found in app/models/automation_task_chief_scout_award.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return ordinalized_date(time, '%H:%M on %A %-d %B')
      Severity: Major
      Found in app/helpers/application_helper.rb - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return "#22ff22"
        Severity: Major
        Found in app/assets/javascripts/application/passwords.js - About 30 mins to fix

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

            def unsubscribed(share)
              @share = share
              mail ({
                :subject => build_subject("Unsubscribed from reminder for #{@share.reminder.section_name} on #{Date::DAYNAMES[@share.reminder.send_on]}"),
                :to => "\"#{@share.name}\" <#{@share.email_address}>",
          Severity: Minor
          Found in app/mailers/email_reminder_mailer.rb and 1 other location - About 25 mins to fix
          app/mailers/email_reminder_mailer.rb on lines 37..41

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

          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

              if @announcement.invalid?
                render action: :new, status: 422
              elsif @announcement.save
                email_to_users if params[:email_to_users]
                redirect_to announcements_path, notice: 'Announcement was successfully created.'
          Severity: Minor
          Found in app/controllers/announcements_controller.rb and 1 other location - About 25 mins to fix
          app/controllers/announcements_controller.rb on lines 44..51

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

          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

              if @announcement.invalid?
                render action: :edit, status: 422
              elsif @announcement.save
                email_to_users if params[:email_to_users]
                redirect_to announcements_path, notice: 'Announcement was successfully updated.'
          Severity: Minor
          Found in app/controllers/announcements_controller.rb and 1 other location - About 25 mins to fix
          app/controllers/announcements_controller.rb on lines 31..38

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

          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 subscribed(share)
              @share = share
              mail ({
                :subject => build_subject("Subscribed to reminder for #{@share.reminder.section_name} on #{Date::DAYNAMES[@share.reminder.send_on]}"),
                :to => "\"#{@share.name}\" <#{@share.email_address}>",
          Severity: Minor
          Found in app/mailers/email_reminder_mailer.rb and 1 other location - About 25 mins to fix
          app/mailers/email_reminder_mailer.rb on lines 45..49

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

          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 scheduled_jobs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def scheduled_jobs
              return @scheduled_jobs unless @scheduled_jobs.nil?
          
              job_status = lambda do |job|
                return :running if job.locked_at
          Severity: Minor
          Found in app/models/status.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

          Method get_calendar_items_for_section has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.get_calendar_items_for_section(api, section, options)
              [:start, :finish, :include_meetings, :include_events].each do |attr|
                fail ArgumentError, "options doesn't contain a value for :#{attr}" unless options.has_key?(attr)
              end
          
          
          Severity: Minor
          Found in app/models/report.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

          Method update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def update
              @token = params[:token]
              @user = User.load_from_reset_password_token(@token)
          
              if @user && @user.change_password!(params[:password], params[:password_confirmation])
          Severity: Minor
          Found in app/controllers/password_resets_controller.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

          Method sortable_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def sortable_link(column, title=nil)
              css_class = 'sortable'
              title ||= column.titleize
              css_class += (column == sort_column) ? " sortable_current sortable_#{sort_direction}" : ''
              direction = ((column == sort_column) && sort_direction == "asc") ? "desc" : "asc"
          Severity: Minor
          Found in app/helpers/application_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

          Method get_automation_tasks_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.get_automation_tasks_data(date)
              Rails.application.eager_load! unless Rails.application.config.cache_classes  # cache_clases is off in dev and on in prod
              types = Module.constants.map{ |i| i=eval(i.to_s) }
              types.select!{ |i| !i.nil? && i.is_a?(Class) && i.superclass.eql?(AutomationTask) }
          
          
          Severity: Minor
          Found in app/models/statistics.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

          Method delete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def delete
              # Check the confirmation code from the confirm_delete page
              unless session[:delete_my_account_confrmation_code].eql?(params[:confirmation_code])
                redirect_to confirm_delete_my_account_path
                return
          Severity: Minor
          Found in app/controllers/my_account_controller.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

          Method hide has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def hide
              request.format = :js if params[:format].nil?
              @announcement = current_user.current_announcements.are_hideable.find(params[:id])
          
              unless @announcement.nil?
          Severity: Minor
          Found in app/controllers/announcements_controller.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

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

              register_structure.each do |row|
                unless /\A[0-9]{4}-[0-2][0-9]-[0-3][0-9]\Z/.match(row.name).nil?
                  date = Date.strptime(row.name, '%Y-%m-%d')
                  dates_to_check.push date if (date >= earliest) && (date <= latest)
                end
          Severity: Minor
          Found in app/models/email_reminder_item_not_seen.rb and 1 other location - About 20 mins to fix
          app/models/email_reminder_item_advised_absence.rb on lines 21..25

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

          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

              structures.each do |row|
                unless /\A[0-9]{4}-[0-2][0-9]-[0-3][0-9]\Z/.match(row.name).nil?
                  date = Date.strptime(row.name, '%Y-%m-%d')
                  dates_to_check.push date if (date >= earliest) && (date <= latest)
                end
          Severity: Minor
          Found in app/models/email_reminder_item_advised_absence.rb and 1 other location - About 20 mins to fix
          app/models/email_reminder_item_not_seen.rb on lines 14..18

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

          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

            def configuration_is_valid
              config = configuration
              unless config[:the_next_n_weeks] > 0
                errors.add('For how many weeks?', 'Must be greater than 0')
                config[:the_next_n_weeks] = self.class.default_configuration[:the_next_n_weeks]
          Severity: Minor
          Found in app/models/email_reminder_item_advised_absence.rb and 2 other locations - About 15 mins to fix
          app/models/email_reminder_item_not_seen.rb on lines 98..104
          app/models/email_reminder_item_programme.rb on lines 81..87

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

          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

            def configuration_is_valid
              config = configuration
              unless config[:the_last_n_weeks] > 0
                errors.add('For how many weeks?', 'Must be greater than 0')
                config[:the_last_n_weeks] = self.class.default_configuration[:the_last_n_weeks]
          Severity: Minor
          Found in app/models/email_reminder_item_not_seen.rb and 2 other locations - About 15 mins to fix
          app/models/email_reminder_item_advised_absence.rb on lines 107..113
          app/models/email_reminder_item_programme.rb on lines 81..87

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

          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

            def configuration_is_valid
              config = configuration
              unless config[:the_next_n_weeks] > 0
                errors.add('How many weeks into the future?', 'Must be greater than 0')
                config[:the_next_n_weeks] = self.class.default_configuration[:the_next_n_weeks]
          Severity: Minor
          Found in app/models/email_reminder_item_programme.rb and 2 other locations - About 15 mins to fix
          app/models/email_reminder_item_advised_absence.rb on lines 107..113
          app/models/email_reminder_item_not_seen.rb on lines 98..104

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

          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

          Severity
          Category
          Status
          Source
          Language