christabor/flask_jsondash

View on GitHub

Showing 92 of 92 total issues

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

      File handlers.js has 762 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /** global: jsondash */
      /** global: c3 */
      /** global: d3 */
      /** global: venn */
      /** global: Plotly */
      Severity: Major
      Found in flask_jsondash/static/js/handlers.js - About 1 day 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

          File charts_builder.py has 386 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          
          """
          flask_jsondash.charts_builder
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          Severity: Minor
          Found in flask_jsondash/charts_builder.py - About 5 hrs to fix

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

                    if config['js_url']:
                        for i, url in enumerate(config['js_url']):
                            url = '{}{}'.format(js_path, url.split('/')[-1])
                            config['js_url'][i] = url_for('static', filename=url)
            Severity: Major
            Found in flask_jsondash/charts_builder.py and 1 other location - About 4 hrs to fix
            flask_jsondash/charts_builder.py on lines 121..124

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

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                    if config['css_url']:
                        for i, url in enumerate(config['css_url']):
                            url = '{}{}'.format(css_path, url.split('/')[-1])
                            config['css_url'][i] = url_for('static', filename=url)
            Severity: Major
            Found in flask_jsondash/charts_builder.py and 1 other location - About 4 hrs to fix
            flask_jsondash/charts_builder.py on lines 117..120

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

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

              File schema.py has 295 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # -*- coding: utf-8 -*-
              
              """
              flask_jsondash.schema
              ~~~~~~~~~~~~~~~~~~~~~
              Severity: Minor
              Found in flask_jsondash/schema.py - About 3 hrs to fix

                Function handleC3 has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                jsondash.handlers.handleC3 = function(container, config) {
                    var _width = isNaN(config.width) ? jsondash.getDynamicWidth(container, config) : config.width;
                    'use strict';
                    var init_config = {
                        bindto: '[data-guid="' + config.guid + '"] .chart-container',
                Severity: Major
                Found in flask_jsondash/static/js/handlers.js - About 2 hrs to fix

                  Function handleTreemap has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  jsondash.handlers.handleTreemap = function(container, config) {
                      'use strict';
                      // Adapted from http://bl.ocks.org/mbostock/4063582
                      var margin = {
                          top: jsondash.config.WIDGET_MARGIN_Y / 2,
                  Severity: Major
                  Found in flask_jsondash/static/js/handlers.js - About 2 hrs to fix

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

                    describe('translateStr', function(){
                        it('should create the string for a svg translation value', function(){
                            expect(jsondash.util.translateStr(10, 20)).toBe('translate(10,20)');
                            expect(jsondash.util.translateStr('50%', '50%')).toBe('translate(50%,50%)');
                        });
                    Severity: Major
                    Found in test_js/utilsSpec.js and 1 other location - About 2 hrs to fix
                    test_js/utilsSpec.js on lines 42..47

                    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

                    describe('scaleStr', function(){
                        it('should create the string for a svg scale value', function(){
                            expect(jsondash.util.scaleStr(10, 20)).toBe('scale(10,20)');
                            expect(jsondash.util.scaleStr('50%', '50%')).toBe('scale(50%,50%)');
                        });
                    Severity: Major
                    Found in test_js/utilsSpec.js and 1 other location - About 2 hrs to fix
                    test_js/utilsSpec.js on lines 35..40

                    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

                    Function update has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def update(c_id):
                        """Normalize the form POST and setup the json view config object."""
                        if not auth(authtype='update'):
                            flash('You do not have access to update dashboards.', 'error')
                            return redirect(url_for('jsondash.dashboard'))
                    Severity: Minor
                    Found in flask_jsondash/charts_builder.py - 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

                            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

                    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

                      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

                                          assets['js'] += [
                                              js for js in settings.CHARTS_CONFIG[dep]['js_url']
                                              if js not in assets['js']
                      Severity: Major
                      Found in flask_jsondash/charts_builder.py and 1 other location - About 1 hr to fix
                      flask_jsondash/charts_builder.py on lines 227..229

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

                      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

                                          assets['css'] += [
                                              css for css in settings.CHARTS_CONFIG[dep]['css_url']
                                              if css not in assets['css']]
                      Severity: Major
                      Found in flask_jsondash/charts_builder.py and 1 other location - About 1 hr to fix
                      flask_jsondash/charts_builder.py on lines 231..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 49.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Severity
                      Category
                      Status
                      Source
                      Language