Showing 141 of 141 total issues
Function initialize
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
* initialize(next) {
logger("using leafjs socketio middleware");
let leaf = this;
let koa = leaf.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 initialize
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
* initialize(next) {
let koa = this.koa;
logger("using leafjs body middleware");
Function constructor
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor() {
function serviceUp(service) {
logger(`serviceup: ${service.type.name}`, service);
if (service.type.name !== "leaf") {
logger('ignoring service, service name not leaf');
Function bodyParseMiddleware
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
koa.use(function* bodyParseMiddleware(next) {
let body, parts;
let contentType = this.req.headers['content-type'],
contentLength = this.req.headers["content-length"],
transferEncoding = this.req.headers["transfer-encoding"];
Function handler
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
function handler(origHeaders) {
logger("delete accept-encoding in origHeaders");
delete origHeaders["accept-encoding"];
return function _handler(method, route, data, headers, cb) {
logger(`trigger socket.io s handler, with (${method}, ${route}, ${data}, ${headers})`);
Function constructor
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
constructor() {
function serviceUp(service) {
logger(`serviceup: ${service.type.name}`, service);
if (service.type.name !== "leaf") {
logger('ignoring service, service name not leaf');
- 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 decorate
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports = module.exports = function decorate(leaf, options) {
options = options || {};
let koa = leaf.koa;
// koa request
Function _handler
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
return function _handler(method, route, data, headers, cb) {
logger(`trigger socket.io s handler, with (${method}, ${route}, ${data}, ${headers})`);
if (undefined === cb) { //arguments is method, route, headers, cb
cb = headers;
headers = data;
Function decorate
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports = module.exports = function decorate(req) {
/**
* Intiate a login session for `user`.
*
Similar blocks of code found in 2 locations. Consider refactoring. Open
it('websocket: should have a get(/test/:name)', function(done) {
sio.emit('s', "get", "/test/chrisye", {}, {}, function(status, headers, body) {
expect(status).eql(200);
expect(body).eql('getchrisye');
done();
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 76.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
it('websocket: should have a get(/test)', function(done) {
sio.emit('s', "get", "/test", {}, {}, function(status, headers, body) {
expect(status).eql(200);
expect(body).eql('get');
done();
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 76.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function initialize
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
* initialize(next) {
logger("using leaf static server middleware");
let leaf = this;
let koa = this.koa;
Function startServer
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
let serverMw = function* startServer(next) {
logger("require pmx and initalizing");
require("pmx").init();
yield * next;
Function staticServer
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
koa.use(function* staticServer(next) {
let path = options.uri;
if (this.request.path) {
if (leaf.namespace && leaf.namespace !== "/") {
path = leaf.namespace + path;
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(".")}`);
Identical blocks of code found in 2 locations. Consider refactoring. Open
after(function(done) {
this.timeout(5000);
app.close().then(function() {
done();
}, function(err) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 67.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
after(function(done) {
this.timeout(5000);
app.close().then(function() {
done();
}, function(err) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 67.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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"