Function getLatest
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
function getLatest (node: RSNode): any {
if (typeof (node) !== 'object' || typeof (node.path) !== 'string') {
return;
}
if (isFolder(node.path)) {
- 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 put
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
async put (path: string, body: unknown, contentType: string): Promise<RSNodes> {
const paths = pathsFromRoot(path);
function _processNodes(nodePaths: string[], nodes: RSNodes): RSNodes {
try {
- 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 _doUpdateNodes
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private _doUpdateNodes(paths: string[], _processNodes: ProcessNodes, promise) {
if (this._updateNodesRunning) {
this._updateNodesQueued.push({
paths: paths,
cb: _processNodes,
Function get
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
async get (path: string, maxAge: number, queueGetRequest: (path2: string) => Promise<QueuedRequestResponse>): Promise<QueuedRequestResponse> {
if (typeof (maxAge) === 'number') {
return this.getNodes(pathsFromRoot(path))
.then((objs) => {
Function put
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
async put (path: string, body: unknown, contentType: string): Promise<RSNodes> {
const paths = pathsFromRoot(path);
function _processNodes(nodePaths: string[], nodes: RSNodes): RSNodes {
try {
Function delete
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
delete (path: string): unknown {
const paths = pathsFromRoot(path);
return this._updateNodes(paths, function (nodePaths, nodes) {
for (let i = 0, len = nodePaths.length; i < len; i++) {
Function getLatest
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getLatest (node: RSNode): any {
if (typeof (node) !== 'object' || typeof (node.path) !== 'string') {
return;
}
if (isFolder(node.path)) {
Function migrate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
migrate(node: RSNode): RSNode {
if (typeof (node) === 'object' && !node.common) {
node.common = {};
if (typeof (node.path) === 'string') {
if (node.path.substr(-1) === '/' && typeof (node.body) === 'object') {
- 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 _processNodes
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _processNodes(nodePaths: string[], nodes: RSNodes): RSNodes {
try {
for (let i = 0, len = nodePaths.length; i < len; i++) {
const nodePath = nodePaths[i];
let node = nodes[nodePath];
Avoid deeply nested control flow statements. Open
if (node.itemsMap.hasOwnProperty(i) && node.itemsMap[i] === false) {
delete node.itemsMap[i];
}
Avoid too many return
statements within this function. Open
return node.common;
Avoid too many return
statements within this function. Open
return {
body: node.body,
contentType: node.contentType
};
Avoid too many return
statements within this function. Open
return;
Function isOutdated
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function isOutdated (nodes: RSNodes, maxAge: number): boolean {
for (const path in nodes) {
if (nodes[path] && nodes[path].remote) {
return true;
}
- 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"