robertgauld/OSMExtender

View on GitHub

Showing 203 of 203 total issues

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

$(document).ready(function() {
    $('.leader_access_audit_select_group').click(function(){
        $('.leader_access_audit_group-' + $(this).data('group-id')).prop('checked', this.checked);
    });
});
Severity: Major
Found in app/assets/javascripts/reports/index.js and 3 other locations - About 2 hrs to fix
app/assets/javascripts/osm_search_members/search_form.js on lines 1..5
app/assets/javascripts/osm_search_members/search_form.js on lines 7..11
app/assets/javascripts/reports/index.js on lines 1..5

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

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

$(document).ready(function() {  
    $('.select_all_section').click(function(){
        $('.section-' + $(this).data('section-id')).prop('checked', this.checked);
    });
});
Severity: Major
Found in app/assets/javascripts/osm_search_members/search_form.js and 3 other locations - About 2 hrs to fix
app/assets/javascripts/osm_search_members/search_form.js on lines 7..11
app/assets/javascripts/reports/index.js on lines 1..5
app/assets/javascripts/reports/index.js on lines 20..24

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

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

$(document).ready(function() {  
    $('.select_all_field').click(function(){
        $('.field-' + $(this).data('field-id')).prop('checked', this.checked);
    });
});
Severity: Major
Found in app/assets/javascripts/osm_search_members/search_form.js and 3 other locations - About 2 hrs to fix
app/assets/javascripts/osm_search_members/search_form.js on lines 1..5
app/assets/javascripts/reports/index.js on lines 1..5
app/assets/javascripts/reports/index.js on lines 20..24

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

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

$(document).ready(function() {  
    $('.calendar_select_all_section').click(function(){
        $('.calendar_section-' + $(this).data('section-id')).prop('checked', this.checked);
    });
});
Severity: Major
Found in app/assets/javascripts/reports/index.js and 3 other locations - About 2 hrs to fix
app/assets/javascripts/osm_search_members/search_form.js on lines 1..5
app/assets/javascripts/osm_search_members/search_form.js on lines 7..11
app/assets/javascripts/reports/index.js on lines 20..24

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

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 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    success: function(data, status, jqXHR) {
      var number_desired_steps = 5;
      var day_desired_steps = 5;
      var item_desired_steps = 5;

Severity: Minor
Found in app/assets/javascripts/statistics/email_reminders.js - About 1 hr to fix

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

      def event_attendance
        require_section_type Constants::YOUTH_AND_ADULT_SECTIONS
        require_osm_permission(:read, :events)
        return if performed? # The above either redirected or rendered
    
    
    Severity: Minor
    Found in app/controllers/reports_controller.rb - About 1 hr to fix

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

      function setRowHeight(to) {
        $('.row_head').css('height', to);
        $('.row_data').css('height', to);
        $('.row_total').css('height', to);
        $('.row_count').css('height', to);
      Severity: Major
      Found in app/assets/javascripts/osm_details/show.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/osm_flexi_records/show.js on lines 8..13

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

      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

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

      function setRowHeight(to) {
        $('.row_head').css('height', to);
        $('.row_data').css('height', to);
        $('.row_total').css('height', to);
        $('.row_count').css('height', to);
      Severity: Major
      Found in app/assets/javascripts/osm_flexi_records/show.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/osm_details/show.js on lines 8..13

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

      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 calendar has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def calendar
          dates = [Osm.parse_date(@my_params[:start]), Osm.parse_date(@my_params[:finish])]
          if dates.include?(nil)
            flash[:error] = 'You failed to provide at least one of the dates.'
            redirect_back_or_to reports_path
      Severity: Minor
      Found in app/controllers/reports_controller.rb - About 1 hr to fix

        Method missing_badge_requirements has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def missing_badge_requirements
            require_section_type Constants::YOUTH_SECTIONS
            require_osm_permission(:read, :badge)
            return if performed? # The above either redirected or rendered
        
        
        Severity: Minor
        Found in app/controllers/reports_controller.rb - About 1 hr to fix

          Method check_osm_setup has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def check_osm_setup
              sections = Osm::Section.get_all(osm_api, :no_cache => true)
          
              Osm::Model.cache_delete(osm_api, ['permissions', osm_api.user_id]) # Clear cached user permissions
              @other_sections = Array.new
          Severity: Minor
          Found in app/controllers/static_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_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_data
              data = []
              earliest = configuration[:the_last_n_months].months.ago.to_date
              latest = configuration[:the_next_n_months].months.from_now.to_date
          
          
          Severity: Minor
          Found in app/models/email_reminder_item_birthday.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 index has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def index
              @sections = Osm::Section.get_all(osm_api)
          
              if has_osm_permission?(:read, :member)
                @groupings = get_current_section_groupings.sort do |a,b|
          Severity: Minor
          Found in app/controllers/reports_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

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

                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 and 1 other location - About 1 hr to fix
          app/assets/javascripts/programme_review/balanced.js on lines 22..22

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

          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

                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'];
          Severity: Major
          Found in app/assets/javascripts/programme_review/balanced.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/programme_review/balanced.js on lines 23..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 70.

          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

                var item_options = {
                  focusTarget: 'category',
                  hAxis: {
                    minValue: 0,
                    gridlines: {
          Severity: Major
          Found in app/assets/javascripts/statistics/automation_tasks.js and 2 other locations - About 1 hr to fix
          app/assets/javascripts/statistics/email_reminders.js on lines 21..31
          app/assets/javascripts/statistics/email_reminders.js on lines 51..61

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

          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

                var item_options = {
                  focusTarget: 'category',
                  hAxis: {
                    minValue: 0,
                    gridlines: {
          Severity: Major
          Found in app/assets/javascripts/statistics/email_reminders.js and 2 other locations - About 1 hr to fix
          app/assets/javascripts/statistics/automation_tasks.js on lines 19..29
          app/assets/javascripts/statistics/email_reminders.js on lines 21..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 69.

          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

                var number_options = {
                  focusTarget: 'category',
                  vAxis: {
                    minValue: 0,
                    gridlines: {
          Severity: Major
          Found in app/assets/javascripts/statistics/email_reminders.js and 2 other locations - About 1 hr to fix
          app/assets/javascripts/statistics/automation_tasks.js on lines 19..29
          app/assets/javascripts/statistics/email_reminders.js on lines 51..61

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

          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 drawChart has 40 lines of code (exceeds 25 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 1 hr to fix

            Method become has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              def become
                user = User.find(params[:id])
                if user
                  current_user = user
                  session[:user_id] = user.id
            Severity: Minor
            Found in app/controllers/users_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

            Severity
            Category
            Status
            Source
            Language