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;
- Read upRead up
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;
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
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];
- Read upRead up
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.
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();
}
- Read upRead up
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()) {
- Read upRead up
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()) {
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()) {
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];
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()) {
- Read upRead up
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];
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();
}
Function configure
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Cart.configure = function (name, forceCookie, currency, bootstrap, striped, alerts) {
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++) {
- Read upRead up
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 = '$';
- Read upRead up
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"