stpettersens/Cart

View on GitHub

Showing 16 of 30 total issues

Function Cart has a Cognitive Complexity of 141 (exceeds 5 allowed). Consider refactoring.
Open

var Cart = (function () {
    function Cart() {
    }
    Cart.isStorageSupported = function () {
        var storage = false;
Severity: Minor
Found in cart.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

Function Cart has 273 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var Cart = (function () {
    function Cart() {
    }
    Cart.isStorageSupported = function () {
        var storage = false;
Severity: Major
Found in cart.js - About 1 day to fix

    File cart.js has 275 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
    A shopping cart implemented via the client-side in TypeScript.
    Copyright 2015 Sam Saint-Pettersen.
    Released under the MIT License.
    https://github.com/stpettersens/Cart
    Severity: Minor
    Found in cart.js - About 2 hrs to fix

      Function removeIt has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          private static removeIt(value: string): void {
              // Use localStorage when possible.
              if(!Cart.forceCookie && Cart.isStorageSupported()) {
                  var a_value: string[] = value.split('(');
                  if(a_value[1] != null) value = a_value[0];
      Severity: Minor
      Found in Cart.ts - 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

      File Cart.ts has 270 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*
          A shopping cart implemented via the client-side in TypeScript.
      
          Copyright 2015 Sam Saint-Pettersen.
          Released under the MIT License.
      Severity: Minor
      Found in Cart.ts - About 2 hrs to fix

        Function getNumberItems has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            private static getNumberItems(): number {
                Cart.reset();
                if(!Cart.forceCookie && Cart.isStorageSupported()) {
                    Cart.pushFromStorage();
                }
        Severity: Minor
        Found in Cart.ts - 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

        Function empty has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public static empty(noprompt?: boolean): void {
                if(!noprompt)
                    var empty: boolean = confirm('Really empty the ' + Cart.cart.toLowerCase() + '?');
                if(empty || noprompt) {
                    if(!Cart.forceCookie && Cart.isStorageSupported()) {
        Severity: Minor
        Found in Cart.ts - 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 renderItems has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static renderItems(): string[] {
                var total: number = 0;
                var c: string = Cart.currency;
                Cart.reset();
                if(!Cart.forceCookie && Cart.isStorageSupported()) {
        Severity: Minor
        Found in Cart.ts - About 1 hr to fix

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

              Cart.renderItems = function () {
                  var total = 0;
                  var c = Cart.currency;
                  Cart.reset();
                  if (!Cart.forceCookie && Cart.isStorageSupported()) {
          Severity: Minor
          Found in cart.js - About 1 hr to fix

            Function removeIt has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                Cart.removeIt = function (value) {
                    if (!Cart.forceCookie && Cart.isStorageSupported()) {
                        var a_value = value.split('(');
                        if (a_value[1] != null)
                            value = a_value[0];
            Severity: Minor
            Found in cart.js - About 1 hr to fix

              Function renderItems has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static renderItems(): string[] {
                      var total: number = 0;
                      var c: string = Cart.currency;
                      Cart.reset();
                      if(!Cart.forceCookie && Cart.isStorageSupported()) {
              Severity: Minor
              Found in Cart.ts - 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 removeIt has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static removeIt(value: string): void {
                      // Use localStorage when possible.
                      if(!Cart.forceCookie && Cart.isStorageSupported()) {
                          var a_value: string[] = value.split('(');
                          if(a_value[1] != null) value = a_value[0];
              Severity: Minor
              Found in Cart.ts - About 1 hr to fix

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

                    Cart.getNumberItems = function () {
                        Cart.reset();
                        if (!Cart.forceCookie && Cart.isStorageSupported()) {
                            Cart.pushFromStorage();
                        }
                Severity: Minor
                Found in cart.js - About 1 hr to fix

                  Function configure has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      Cart.configure = function (name, forceCookie, currency, bootstrap, striped, alerts) {
                  Severity: Minor
                  Found in cart.js - About 45 mins to fix

                    Function pushFromCookie has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private static pushFromCookie(): void {
                            var cookie = $.cookie(Cart.cookie);
                            var values: string[] = new Array<string>();
                            if(cookie != undefined) values = cookie.split(',');
                            for(var i: number = 0; i < values.length; i++) {
                    Severity: Minor
                    Found in Cart.ts - 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

                    Function configure has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static configure(name?: string, forceCookie?: boolean, currency?: string, bootstrap?: boolean, striped?: boolean, alerts?: boolean): void {
                            if(name != null) Cart.cart = name;
                            if(forceCookie != null) Cart.forceCookie = forceCookie;
                            if(currency != null) Cart.currency = currency;
                            else Cart.currency = '$';
                    Severity: Minor
                    Found in Cart.ts - 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

                    Severity
                    Category
                    Status
                    Source
                    Language