Showing 13 of 71 total issues
Function delete
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
delete(pos: number): SinglyLinkedList<T> {
if (this.size === 0) throw "Can not delete from an empty list";
if (this.size - 1 < pos) throw "Index out of bounds.";
if (this.size === 1) {
this.head = null;
- 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 _delete
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function _delete<T>(root: BSTreeNode<T>, data: T): BSTreeNode<T> | null {
if (root.data > data) {
root.left = _delete(root.left as BSTreeNode<T>, data);
return root;
} else if (root.data < data) {
- 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 delete
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
delete(pos: number): SinglyLinkedList<T> {
if (this.size === 0) throw "Can not delete from an empty list";
if (this.size - 1 < pos) throw "Index out of bounds.";
if (this.size === 1) {
this.head = null;
Function insert
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
insert(data: T, pos?: number): DoublyLinkedList<T> {
const newNode = new DoublyLinkedListNode(data);
if (pos === undefined) pos = this.size;
Function delete
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
delete(pos: number): DoublyLinkedList<T> {
if (this.size === 0) throw "Can not delete from an empty list";
if (this.size - 1 < pos) throw "Index out of bounds.";
if (this.size === 1) {
return _emptyList(this);
- 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 insert
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
insert(data: T, pos: number): SinglyLinkedList<T> {
const newNode = new SinglyLinkedListNode<T>(data);
if (this.size < pos) throw "Index out of bounds.";
if (this.size === 0) this.head = newNode;
- 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 insert
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
insert(data: T, pos?: number): DoublyLinkedList<T> {
const newNode = new DoublyLinkedListNode(data);
if (pos === undefined) pos = this.size;
- 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 removeVertex
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
removeVertex(vertex: string): Graph {
if (!this._graph[vertex])
throw "Can not remove a vertex that does not exist.";
delete this._graph[vertex];
for (const [k, v] of Object.entries(this._graph)) {
- 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
Avoid too many return
statements within this function. Open
return root;
Function _search
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function _search<T>(root: BSTreeNode<T> | null, data: any): BSTreeNode<T> | -1 {
if (!root) return -1;
return data > root.data
? _search(root.right, data)
: data < root.data
- 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 _heapifyDown
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
_heapifyDown(): void {
let index = 0;
while (this._hasLeftChild(index)) {
let childIndex = this._getLeftChildIndex(index);
const lChild = this._leftChild(index);
- 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 addEdge
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
addEdge(u: string, v: string, w: number = 1): Graph {
if (!this.weighted && w != 1)
throw "Can not pass weight to unweighted graph.";
if (!this._graph[u] || !this._graph[v])
throw "Can not add edge between undefined edges.";
- 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 view
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
view(): Stack<T> {
if (this.data.length == 0) throw "Can not view an empty stack.";
let log = "";
for (let i = this.data.length - 1; i >= 0; i--) {
log +=
- 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"