balanced/balanced-dashboard

View on GitHub
app/lib/utils.js

Summary

Maintainability
D
1 day
Test Coverage

Utils has 40 functions (exceeds 20 allowed). Consider refactoring.
Open

var Utils = Ember.Namespace.create({

    toDataUri: function(string) {
        return "data:text/plain;charset=utf-8;base64," + window.btoa(string);
    },
Severity: Minor
Found in app/lib/utils.js - About 5 hrs to fix

    File utils.js has 371 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import Ember from "ember";
    import Constants from "balanced-dashboard/utils/constants";
    
    var FORMAT_NUMBER_REGEX = /\B(?=(\d{3})+(?!\d))/g,
        PRETTY_LOG_URL_REGEX = /\/marketplaces\/[^\/]*\/(.+)$/,
    Severity: Minor
    Found in app/lib/utils.js - About 4 hrs to fix

      Function applyUriFilters has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          applyUriFilters: function(uri, params) {
              if (!uri) {
                  return uri;
              }
      
      
      Severity: Minor
      Found in app/lib/utils.js - About 1 hr to fix

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

            formatError: function(error) {
                if (error !== null && error !== undefined) {
                    if (error.message) {
                        // amount validation
                        return error.message;
        Severity: Minor
        Found in app/lib/utils.js - 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 applyUriFilters has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            applyUriFilters: function(uri, params) {
                if (!uri) {
                    return uri;
                }
        
        
        Severity: Minor
        Found in app/lib/utils.js - About 55 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 formatFileSize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            formatFileSize: function(bytes) {
                if (bytes >= 1000000000) {
                    bytes = (bytes / 1000000000).toFixed(2) + ' gb';
                } else if (bytes >= 1000000) {
                    bytes = (bytes / 1000000).toFixed(2) + ' mb';
        Severity: Minor
        Found in app/lib/utils.js - About 25 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

        There are no issues that match your filters.

        Category
        Status