AgileVentures/MetPlus_PETS

View on GitHub
app/assets/javascripts/agency_admin.js

Summary

Maintainability
F
3 days
Test Coverage

`` has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

var AgencyData = {
  add_job_category: function () {
    // this function is bound to 'click' event on 'Add Category' button
    // in Bootstrap modal:  'agency_admin/_property_modal.html.haml'
    AgencyData.add_job_property('job_category', 'job_categories',
Severity: Minor
Found in app/assets/javascripts/agency_admin.js - About 3 hrs to fix

    File agency_admin.js has 282 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var AgencyData = {
      add_job_category: function () {
        // this function is bound to 'click' event on 'Add Category' button
        // in Bootstrap modal:  'agency_admin/_property_modal.html.haml'
        AgencyData.add_job_property('job_category', 'job_categories',
    Severity: Minor
    Found in app/assets/javascripts/agency_admin.js - About 2 hrs to fix

      Function delete_job_property has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

        delete_job_property: function (job_property, job_prop_plural, delete_url) {
          // This functions handles the event created when the
          // delete <property> link is clicked on the page.
      
          // The arguments are:
      Severity: Minor
      Found in app/assets/javascripts/agency_admin.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

      Function delete_job_property has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        delete_job_property: function (job_property, job_prop_plural, delete_url) {
          // This functions handles the event created when the
          // delete <property> link is clicked on the page.
      
          // The arguments are:
      Severity: Minor
      Found in app/assets/javascripts/agency_admin.js - About 1 hr to fix

        Function add_job_property has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          add_job_property: function (job_property, job_prop_plural, attr1, attr2) {
            // This functions handles the event created when the
            // "Add <property>" button is clicked on the bootstrap modal.
        
            // The arguments are:
        Severity: Minor
        Found in app/assets/javascripts/agency_admin.js - About 1 hr to fix

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

                      success: function (data, status, xhrObject) {
          
                        var company_id = null;
                        if ($('#company_id') != null) {
                          company_id = $('#company_id').val();
          Severity: Minor
          Found in app/assets/javascripts/agency_admin.js - About 1 hr to fix

            Function update_job_property has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              update_job_property: function (job_property, job_prop_plural, attr1, attr2) {
                // This functions handles the event created when the
                // "Update <property>" button is clicked on the bootstrap modal.
            
                // The arguments are:
            Severity: Minor
            Found in app/assets/javascripts/agency_admin.js - About 1 hr to fix

              Function change_job_property_success has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                change_job_property_success: function (modal_id, model_errors_id,
                                                       job_prop_plural, company_id,
                                                       user_type) {
              Severity: Minor
              Found in app/assets/javascripts/agency_admin.js - About 35 mins to fix

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

                  setup_manage_skill: function () {
                    $('#add_skill_button').click(AgencyData.add_skill);
                    $('#skills_table').on('click',
                                  // bind to 'edit skill' anchor element
                                  "a[href^='/skills/'][data-method='edit']",
                Severity: Major
                Found in app/assets/javascripts/agency_admin.js and 2 other locations - About 2 hrs to fix
                app/assets/javascripts/agency_admin.js on lines 387..398
                app/assets/javascripts/agency_admin.js on lines 411..422

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

                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

                  setup_manage_license: function () {
                    $('#add_license_button').click(AgencyData.add_license);
                    $('#licenses_table').on('click',
                                  // bind to 'edit license' anchor element
                                  "a[href^='/licenses/'][data-method='edit']",
                Severity: Major
                Found in app/assets/javascripts/agency_admin.js and 2 other locations - About 2 hrs to fix
                app/assets/javascripts/agency_admin.js on lines 387..398
                app/assets/javascripts/agency_admin.js on lines 399..410

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

                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

                  setup_manage_job_category: function () {
                    $('#add_job_category_button').click(AgencyData.add_job_category);
                    $('#job_categories_table').on('click',
                                  // bind to 'edit category' anchor element
                                  "a[href^='/job_categories/'][data-method='edit']",
                Severity: Major
                Found in app/assets/javascripts/agency_admin.js and 2 other locations - About 2 hrs to fix
                app/assets/javascripts/agency_admin.js on lines 399..410
                app/assets/javascripts/agency_admin.js on lines 411..422

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

                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

                  edit_license: function () {
                    // Get the url from the anchor element that was clicked
                    var url = $(this).attr('href');
                    AgencyData.edit_job_property('license', url,
                                                 'abbr', 'title');
                Severity: Minor
                Found in app/assets/javascripts/agency_admin.js and 2 other locations - About 40 mins to fix
                app/assets/javascripts/agency_admin.js on lines 86..92
                app/assets/javascripts/agency_admin.js on lines 93..99

                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

                  edit_skill: function () {
                    // Get the url from the anchor element that was clicked
                    var url = $(this).attr('href');
                    AgencyData.edit_job_property('skill', url,
                                                 'name', 'description');
                Severity: Minor
                Found in app/assets/javascripts/agency_admin.js and 2 other locations - About 40 mins to fix
                app/assets/javascripts/agency_admin.js on lines 86..92
                app/assets/javascripts/agency_admin.js on lines 100..106

                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

                  edit_job_category: function () {
                    // Get the url from the anchor element that was clicked
                    var url = $(this).attr('href');
                    AgencyData.edit_job_property('job_category', url,
                                                 'name', 'description');
                Severity: Minor
                Found in app/assets/javascripts/agency_admin.js and 2 other locations - About 40 mins to fix
                app/assets/javascripts/agency_admin.js on lines 93..99
                app/assets/javascripts/agency_admin.js on lines 100..106

                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

                  delete_skill: function () {
                    // Get the url from the anchor element that was clicked
                    var url = $(this).attr('href');
                    AgencyData.delete_job_property('skill', 'skills', url);
                    return false;
                Severity: Minor
                Found in app/assets/javascripts/agency_admin.js and 2 other locations - About 35 mins to fix
                app/assets/javascripts/agency_admin.js on lines 214..219
                app/assets/javascripts/agency_admin.js on lines 228..233

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

                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

                  delete_job_category: function () {
                    // Get the url from the anchor element that was clicked
                    var url = $(this).attr('href');
                    AgencyData.delete_job_property('job_category', 'job_categories', url);
                    return false;
                Severity: Minor
                Found in app/assets/javascripts/agency_admin.js and 2 other locations - About 35 mins to fix
                app/assets/javascripts/agency_admin.js on lines 221..226
                app/assets/javascripts/agency_admin.js on lines 228..233

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

                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

                  delete_license: function () {
                    // Get the url from the anchor element that was clicked
                    var url = $(this).attr('href');
                    AgencyData.delete_job_property('license', 'licenses', url);
                    return false;
                Severity: Minor
                Found in app/assets/javascripts/agency_admin.js and 2 other locations - About 35 mins to fix
                app/assets/javascripts/agency_admin.js on lines 214..219
                app/assets/javascripts/agency_admin.js on lines 221..226

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

                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

                There are no issues that match your filters.

                Category
                Status