christabor/flask_jsondash

View on GitHub
flask_jsondash/static/js/app.js

Summary

Maintainability
F
1 wk
Test Coverage

Function jsondash has 839 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var jsondash = function() {
    var my = {
        chart_wall: null
    };
    var MIN_CHART_SIZE   = 200;
Severity: Major
Found in flask_jsondash/static/js/app.js - About 4 days to fix

    Function jsondash has a Cognitive Complexity of 145 (exceeds 5 allowed). Consider refactoring.
    Open

    var jsondash = function() {
        var my = {
            chart_wall: null
        };
        var MIN_CHART_SIZE   = 200;
    Severity: Minor
    Found in flask_jsondash/static/js/app.js - About 2 days 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

    File app.js has 841 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /** global: d3 */
    /**
     * Bootstrapping functions, event handling, etc... for application.
     */
    
    
    Severity: Major
    Found in flask_jsondash/static/js/app.js - About 2 days to fix

      Function Widget has 149 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function Widget(container, config) {
              // model for a chart widget
              var self = this;
              self.config = config;
              self.guid = self.config.guid;
      Severity: Major
      Found in flask_jsondash/static/js/app.js - About 5 hrs to fix

        Function Widgets has 105 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function Widgets() {
                var self = this;
                self.widgets = {};
                self.url_cache = {};
                self.container = MAIN_CONTAINER.selector;
        Severity: Major
        Found in flask_jsondash/static/js/app.js - About 4 hrs to fix

          Function addDomEvents has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function addDomEvents() {
                  MAIN_FORM.find('[name="mode"]').on('change.charts.row', chartsModeChanged);
                  WIDGET_FORM.find('[name="row"]').on('change.charts.row', chartsRowChanged);
                  // Chart type change
                  WIDGET_FORM.find('[name="type"]').on('change.charts.type', chartsTypeChanged);
          Severity: Major
          Found in flask_jsondash/static/js/app.js - About 2 hrs to fix

            Function loadAll has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    self.loadAll = function() {
                        // Don't run this on certain types that are not cacheable (e.g. binary, html)
                        var config_urls = self.getAllOfPropUnless('dataSource', 'family', 'Basic');
                        var unique_urls = d3.set(config_urls).values();
                        var cached = {};
            Severity: Minor
            Found in flask_jsondash/static/js/app.js - About 1 hr to fix

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

                      self.load = function() {
                          var widg      = my.widgets.get(self.guid);
                          var widget    = self.el;
                          var $widget   = self.$el;
                          var config    = widg.config;
              Severity: Minor
              Found in flask_jsondash/static/js/app.js - About 1 hr to fix

                Function populateEditForm has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function populateEditForm(e) {
                        // If the modal caller was the add modal button, skip populating the field.
                        API_PREVIEW.text('...');
                        clearForm();
                        if(isModalButton(e) || isRowButton(e)) {
                Severity: Minor
                Found in flask_jsondash/static/js/app.js - About 1 hr to fix

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

                      function fitGrid(grid_packer_opts, init) {
                          var packer_options = $.isPlainObject(grid_packer_opts) ? grid_packer_opts : {};
                          var grid_packer_options = $.extend({}, packer_options, {});
                          var drag_options = {
                              scroll: true,
                  Severity: Minor
                  Found in flask_jsondash/static/js/app.js - About 1 hr to fix

                    Function loadDashboard has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function loadDashboard(data) {
                            // Load the grid before rendering the ajax, since the DOM
                            // is rendered server side.
                            fitGrid({
                                columnWidth: 5,
                    Severity: Minor
                    Found in flask_jsondash/static/js/app.js - About 1 hr to fix

                      Avoid too many return statements within this function.
                      Open

                              return true;
                      Severity: Major
                      Found in flask_jsondash/static/js/app.js - About 30 mins to fix

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

                                self.getAllMatchingProp = function(propname, val) {
                                    var matches = [];
                                    $.each(self.all(), function(i, widg){
                                        if(widg.config[propname] === val) {
                                            matches.push(widg.config.guid);
                        Severity: Major
                        Found in flask_jsondash/static/js/app.js and 1 other location - About 2 hrs to fix
                        flask_jsondash/static/js/app.js on lines 93..101

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

                                self.getAllOfPropUnless = function(propname, propcheck, val) {
                                    var props = [];
                                    $.each(self.all(), function(i, widg){
                                        if(widg.config[propcheck] !== val) {
                                            props.push(widg.config[propname]);
                        Severity: Major
                        Found in flask_jsondash/static/js/app.js and 1 other location - About 2 hrs to fix
                        flask_jsondash/static/js/app.js on lines 74..82

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

                                    d3.map(bootstrap_classes, function(i){
                                        var classes = {};
                                        classes['col-md-' + i] = false;
                                        classes['col-lg-' + i] = false;
                                        sel.classed(classes);
                        Severity: Major
                        Found in flask_jsondash/static/js/app.js and 1 other location - About 1 hr to fix
                        flask_jsondash/static/js/app.js on lines 258..263

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

                        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

                                    d3.map(classes, function(colcount){
                                        var classlist = {};
                                        classlist['col-md-' + colcount] = true;
                                        classlist['col-lg-' + colcount] = true;
                                        sel.classed(classlist);
                        Severity: Major
                        Found in flask_jsondash/static/js/app.js and 1 other location - About 1 hr to fix
                        flask_jsondash/static/js/app.js on lines 267..272

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 67.

                        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

                                ADD_MODULE.on('click.charts', function(){
                                    UPDATE_FORM_BTN
                                    .attr('id', SAVE_WIDGET_BTN.selector.replace('#', ''))
                                    .text('Save widget')
                                    .off('click.charts.save')
                        Severity: Major
                        Found in flask_jsondash/static/js/app.js and 1 other location - About 1 hr to fix
                        flask_jsondash/static/js/app.js on lines 210..216

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

                        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

                                    self.$el.find('.widget-edit').on('click.charts', function(){
                                        SAVE_WIDGET_BTN
                                        .attr('id', UPDATE_FORM_BTN.selector.replace('#', ''))
                                        .text('Update widget')
                                        .off('click.charts.save')
                        Severity: Major
                        Found in flask_jsondash/static/js/app.js and 1 other location - About 1 hr to fix
                        flask_jsondash/static/js/app.js on lines 721..727

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

                        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 loader(container) {
                                container.select('.loader-overlay').classed({hidden: false});
                                container.select('.widget-loader').classed({hidden: false});
                            }
                        Severity: Minor
                        Found in flask_jsondash/static/js/app.js and 1 other location - About 55 mins to fix
                        flask_jsondash/static/js/app.js on lines 698..701

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

                        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 unload(container) {
                                container.select('.loader-overlay').classed({hidden: true});
                                container.select('.widget-loader').classed({hidden: true});
                            }
                        Severity: Minor
                        Found in flask_jsondash/static/js/app.js and 1 other location - About 55 mins to fix
                        flask_jsondash/static/js/app.js on lines 693..696

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

                        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