robertgauld/OSMExtender

View on GitHub

Showing 203 of 203 total issues

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

function setTextSize(to) {
  $('.field_head').css('font-size', to);
  $('.field_data').css('font-size', to);
  $('.field_total').css('font-size', to);
  $('.field_count').css('font-size', to);
Severity: Major
Found in app/assets/javascripts/osm_flexi_records/show.js and 1 other location - About 2 hrs to fix
app/assets/javascripts/osm_details/show.js on lines 1..7

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

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

Function success has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    success: function(data, status, jqXHR) {
      var addons_desired_steps = 5;

      $("#section_total").html("The users of OSM Extender have access to " + data["total"] + " unique sections.");

Severity: Major
Found in app/assets/javascripts/statistics/sections.js - About 2 hrs to fix

    Method perform has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def perform
        noterm_emails_sent = {}
        forbidden_emails_sent = {}
        tasks = AutomationTask.where(active: true).order(:section_id)
        count = tasks.count
    Severity: Minor
    Found in app/jobs/automation_tasks_job.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 event_attendance has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.event_attendance(user, section, events, groupings)
        Rails.cache.fetch("user#{user.id}-report-event_attendance-data-#{user.id}-#{section.id}-#{events.inspect}-#{groupings.inspect}", :expires_in => 10.minutes) do
          event_names = []
          row_groups = {}
          member_totals = {}
    Severity: Minor
    Found in app/models/report.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 balanced has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def balanced(start=SECTION_DURATION[@section.type].ago, finish=SECTION_DURATION[@section.type].from_now)
        zones = {:number => {}, :time => {}}
        methods = {:number => {}, :time => {}}
        earliest = Date.current
        latest = Date.current
    Severity: Major
    Found in app/models/programme_review.rb - About 2 hrs to fix

      Function success has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          success: function(data, status, jqXHR) {
            updateStatus('Processing data.');
      
            var number_zones_steps = (data['statistics']['zones']['number']['max_value'] > 5) ?  graphGridLines(data['statistics']['zones']['number']['max_value'], 5) : data['statistics']['zones']['number']['max_value'];
            var number_methods_steps = (data['statistics']['methods']['number']['max_value'] > 5) ? graphGridLines(data['statistics']['methods']['number']['max_value'], 5) : data['statistics']['methods']['number']['max_value'];
      Severity: Major
      Found in app/assets/javascripts/programme_review/balanced.js - About 2 hrs to fix

        Method get_data has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_data
            events = []
            event_list = Osm::Event.get_list(user.osm_api, section_id)
            event_list.reject!{ |e| e[:archived] }
            event_list.each do |event|
        Severity: Minor
        Found in app/models/email_reminder_item_event.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

        Function drawChart has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        function drawChart(data, labels, options, chart, z_or_m, n_or_t) {
          updateStatus('Processing chart data for ' + z_or_m + 's (by ' + n_or_t + ').');
        
          data_table = new google.visualization.DataTable();
          data_table.addColumn({
        Severity: Minor
        Found in app/assets/javascripts/programme_review/balanced.js - 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

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

        function getPasswordStrengthColor(strength) {
            if (strength < 0.000002) {return "#ff2222" }
            if (strength < 0.002) {return "#ff5555" }
            if (strength < 1) {return "#ff8888" }
            if (strength < 10) {return "#99ff99" }
        Severity: Major
        Found in app/assets/javascripts/application/passwords.js and 1 other location - About 2 hrs to fix
        app/assets/javascripts/application/passwords.js on lines 25..32

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

        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

        function getPasswordStrengthDescription(strength) {
            if (strength < 0.000002) {return "Very weak" }
            if (strength < 0.002) {return "Weak" }
            if (strength < 1) {return "Nearly strong enough" }
            if (strength < 10) {return "Strong enough" }
        Severity: Major
        Found in app/assets/javascripts/application/passwords.js and 1 other location - About 2 hrs to fix
        app/assets/javascripts/application/passwords.js on lines 16..23

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

        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

        Consider simplifying this complex logical expression.
        Open

              if PlannedBadgeRequirementsReport.data_for?(
                current_user.id,
                current_section.id,
                start: dates.first,
                finish: dates.last,
        Severity: Critical
        Found in app/controllers/reports_controller.rb - About 2 hrs to fix

          Method initialize has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def initialize(user)
              alias_action :destroy, :to=>:delete
              alias_action :create, :read, :update, :delete, :to=>:administer
          
              # Things everyone can do
          Severity: Major
          Found in app/models/ability.rb - About 2 hrs to fix

            Method perform_task has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def perform_task(user=self.user)
                ret_val = {log_lines: log_lines=[], errors: errors=[]}
            
                section = Osm::Section.get(user.osm_api, section_id)
                if section.nil?
            Severity: Major
            Found in app/models/automation_task_first_aid.rb - About 2 hrs to fix

              File application_controller.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              class ApplicationController < ActionController::Base
                protect_from_forgery :with => :exception
                before_action :require_login
                before_action :require_gdpr_consent
                before_action :set_paper_trail_whodunnit
              Severity: Minor
              Found in app/controllers/application_controller.rb - About 2 hrs to fix

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

                  def planned_badge_requirements
                    require_section_type Constants::YOUTH_SECTIONS
                    require_osm_permission(:read, :programme)
                    require_osm_permission(:read, :events) if current_section.subscription_at_least?(:silver)
                
                
                Severity: Minor
                Found in app/controllers/reports_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

                Function drawCharts has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function drawCharts() {
                  $.ajax({
                    url: 'email_reminders.json',
                    dataType:"json",
                    async: false,
                Severity: Major
                Found in app/assets/javascripts/statistics/email_reminders.js - About 2 hrs to fix

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

                  jQuery(document).ready(function(){
                          $('.accordion_exports h2').click(function() {
                                  $(this).next().toggle('slow');
                                  return false;
                          }).next().hide();
                  Severity: Major
                  Found in app/assets/javascripts/osm_exports/index.js and 2 other locations - About 2 hrs to fix
                  app/assets/javascripts/reports/index.js on lines 27..32
                  app/assets/javascripts/static/help.js on lines 1..6

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

                  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

                  jQuery(document).ready(function(){
                          $('.accordion_faqs h3').click(function() {
                                  $(this).next().toggle('slow');
                                  return false;
                          }).next().hide();
                  Severity: Major
                  Found in app/assets/javascripts/static/help.js and 2 other locations - About 2 hrs to fix
                  app/assets/javascripts/osm_exports/index.js on lines 1..6
                  app/assets/javascripts/reports/index.js on lines 27..32

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

                  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

                  jQuery(document).ready(function(){
                          $('.accordion_reports h2').click(function() {
                                  $(this).next().toggle('slow');
                                  return false;
                          }).next().hide();
                  Severity: Major
                  Found in app/assets/javascripts/reports/index.js and 2 other locations - About 2 hrs to fix
                  app/assets/javascripts/osm_exports/index.js on lines 1..6
                  app/assets/javascripts/static/help.js on lines 1..6

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

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

                    def perform
                      noterm_emails_sent = {}
                      forbidden_emails_sent = {}
                      lists = EmailList.where(:notify_changed => true).order(:section_id)
                      count = lists.count
                  Severity: Minor
                  Found in app/jobs/email_lists_job.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

                  Severity
                  Category
                  Status
                  Source
                  Language