Showing 37 of 141 total issues
Function decorate
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
exports = module.exports = function decorate(leaf, options) {
options = options || {};
let koa = leaf.koa;
// koa request
- 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 constructor
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(mod, config) {
super();
if (!(this instanceof Leaf)) return new Leaf(mod, config);
logger(`root pwd is ${pathModule.resolve(".")}`);
Function get
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
get(name, ver) {
let time = new Date();
// think of a way to refactor this into a generator, so we can just store that as a cache and yield everytime
// hopeful usage would be:
// var service = cache[service@version].next();
Function initialize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
* initialize(next) {
logger("using leaf static server middleware");
let leaf = this;
let koa = this.koa;
- 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 advertise
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
advertise(leaf) {
if (leaf._ad) {
leaf._ad.stop();
}
let adSettings = {
- 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 advertise
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
advertise(leaf) {
if (leaf._ad) {
leaf._ad.stop();
}
let adSettings = {
Function exports
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
exports = module.exports = function(options) {
options = options || {};
if (!options.calculate) {
var hash = options.hash;
- 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 exports
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports = module.exports = function( options ) {
options = options || {};
let hsts;
if (options.hsts) {
Function logIn
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
req.logIn = function (user, options, done) {
if (typeof options == "function") { // arguments is user, done
done = options;
options = {};
}
Function resolver
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function resolver() {
logger("looping through browser caches");
// keep trying for a specific amount of time, now hard coded, 1s
if (new Date() - time > 2000) {
logger("timeout");
Function pushStatic
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.res.pushStatic = ((reqPath, originalPath) => {
let rs = this.res;
if (reqPath.startsWith(path)) {
// first implement a naive implementation
let stream = this.res.push(originalPath, {
Function serviceUp
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function serviceUp(service) {
logger(`serviceup: ${service.type.name}`, service);
if (service.type.name !== "leaf") {
logger('ignoring service, service name not leaf');
return;
Function initialize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
* initialize(next) {
logger("using leaf strengthen middleware");
let koa = this.koa;
Function body
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.req.body = function*() {
logger("req.body req headers:", self.req.headers, body);
if (!self.req.headers["content-length"] && !self.req.headers["transfer-encoding"]) {
logger("it doesnt have content-length neither does it have transfer-encoding, set it empty");
body = {};
Function _request
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
function _request(sc, path, nsp, method, data, headers, resolve, reject) {
Function cacheControl
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
response.cacheControl = function(maxage) {
if (maxage === false) {
this.set('Cache-Control', 'private, no-cache');
return 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 constructor
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
constructor(mod, config) {
super();
if (!(this instanceof Leaf)) return new Leaf(mod, config);
logger(`root pwd is ${pathModule.resolve(".")}`);
- 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"