christabor/flask_jsondash

View on GitHub

Showing 92 of 92 total issues

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

            assets['js'] += [
                js for js in data['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 235..236

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

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

def local_static(chart_config, static_config):
    """Convert remote cdn urls to local urls, based on user provided paths.

    The filename must be identical to the one specified in the
    `settings.py` configuration.
Severity: Minor
Found in flask_jsondash/charts_builder.py - 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

Function handleCirclePack has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

jsondash.handlers.handleCirclePack = function(container, config) {
    'use strict';
    // Adapted from https://bl.ocks.org/mbostock/4063530
    var margin = jsondash.config.WIDGET_MARGIN_Y;
    var diameter = jsondash.getDiameter(container, config) - margin;
Severity: Minor
Found in flask_jsondash/static/js/handlers.js - About 1 hr to fix

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

    jsondash.handlers.handleVoronoi = function(container, config) {
        'use strict';
        jsondash.getJSON(container, config, function(error, data){
            var _width   = isNaN(config.width) ? jsondash.getDynamicWidth(container, config) : config.width;
            var width    = _width - jsondash.config.WIDGET_MARGIN_X;
    Severity: Minor
    Found in flask_jsondash/static/js/handlers.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 handlePlotly has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        jsondash.handlers.handlePlotly = function(container, config) {
            'use strict';
            var id = 'plotly-' + config.guid;
            var _width = isNaN(config.width) ? jsondash.getDynamicWidth(container, config) : config.width;
            container
        Severity: Minor
        Found in flask_jsondash/static/js/handlers.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

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

            jsondash.util.intervalStrToMS = function(ival_fmt) {
                if(ival_fmt === undefined || ival_fmt === '') {
                    return null;
                }
                // Just return number if it's a regular integer.
            Severity: Minor
            Found in flask_jsondash/static/js/utils.js - About 1 hr to fix

              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

                      var svg   = container
                          .select('.chart-container')
                          .append('svg')
                          .classed(jsondash.util.getCSSClasses(config))
                          .classed({'wordcloud': true});
              Severity: Major
              Found in flask_jsondash/static/js/handlers.js and 1 other location - About 1 hr to fix
              flask_jsondash/static/js/handlers.js on lines 250..254

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

              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 svg = container
                          .select('.chart-container')
                          .append('svg')
                          .classed(jsondash.util.getCSSClasses(config))
                          .classed({'chart-graph': true});
              Severity: Major
              Found in flask_jsondash/static/js/handlers.js and 1 other location - About 1 hr to fix
              flask_jsondash/static/js/handlers.js on lines 278..282

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

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

              def get_active_assets(families):
                  """Given a list of chart families, determine what needs to be loaded."""
                  families += REQUIRED_STATIC_FAMILES  # Always load internal, shared libs.
                  assets = dict(css=[], js=[])
                  families = set(families)
              Severity: Minor
              Found in flask_jsondash/charts_builder.py - 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

              Function dump_fixtures has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              def dump_fixtures(path, delete_after=False):
                  """Generate fixture data (json) from existing records in db.
              
                  Args:
                      name (path): The folder path to save configs in (must exist first!)
              Severity: Minor
              Found in flask_jsondash/model_factories.py - 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

              Function handleVegaLite has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              jsondash.handlers.handleVegaLite = function(container, config) {
                  'use strict';
                  jsondash.getJSON(container, config, function(error, vlspec){
                      var SCALE_FACTOR = 0.7; // very important to get sizing jusst right.
                      var selector = '[data-guid="' + config.guid + '"] .chart-container';
              Severity: Minor
              Found in flask_jsondash/static/js/handlers.js - About 1 hr to fix

                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

                Function url2wordcloud has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def url2wordcloud(url, requests_kwargs={},
                Severity: Major
                Found in flask_jsondash/data_utils/wordcloud.py - About 50 mins to fix

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

                      var scale = d3.scale.linear()
                          .clamp(true)
                          .domain([2, 14]) // min/max digits length: $0 - $999,999,999.00
                          .range([90, 30]); // max/min font-size
                  Severity: Minor
                  Found in flask_jsondash/static/js/utils.js and 1 other location - About 50 mins to fix
                  flask_jsondash/static/js/handlers.js on lines 714..717

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

                  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 scale = d3.scale.linear()
                          .clamp(true)
                          .domain([1, 20]) // min/max digits length
                          .range([80, 30]); // max/min font-size
                  Severity: Minor
                  Found in flask_jsondash/static/js/handlers.js and 1 other location - About 50 mins to fix
                  flask_jsondash/static/js/utils.js on lines 176..179

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

                  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