christabor/flask_jsondash

View on GitHub

Showing 54 of 92 total issues

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

    def validate_raw_json(jsonstr, **overrides):
        """Validate the raw json for a config.
    
        Args:
            jsonstr (str): The raw json configuration
    Severity: Minor
    Found in flask_jsondash/schema.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 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

                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

                  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

                    Function view has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def view(c_id):
                        """Load a json view config from the DB."""
                        if not auth(authtype='view', view_id=c_id):
                            flash('You do not have access to view this dashboard.', 'error')
                            return redirect(url_for('jsondash.dashboard'))
                    Severity: Minor
                    Found in flask_jsondash/charts_builder.py - About 45 mins 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 insert_dashboards has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def insert_dashboards(records, max_charts, fixtures, dump, delete):
                    Severity: Minor
                    Found in flask_jsondash/model_factories.py - About 35 mins to fix

                      Function intervalStrToMS has a Cognitive Complexity of 7 (exceeds 5 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 35 mins 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 metadata has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def metadata(key=None, exclude=[]):
                          """An abstraction around misc. metadata.
                      
                          This allows loose coupling for enabling and setting
                          metadata for each chart.
                      Severity: Minor
                      Found in flask_jsondash/charts_builder.py - About 35 mins 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 path_hierarchy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def path_hierarchy(path, hierarchy=[], prev=None):
                          """Create a dotfile representation of a filesystem tree.
                      
                          Format is suitable for graphviz applications.
                          """
                      Severity: Minor
                      Found in flask_jsondash/data_utils/filetree_digraph.py - About 35 mins 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

                      Avoid too many return statements within this function.
                      Open

                              return amt * ms2min;
                      Severity: Major
                      Found in flask_jsondash/static/js/utils.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return amt * ms2day;
                        Severity: Major
                        Found in flask_jsondash/static/js/utils.js - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language