Showing 13 of 13 total issues
Function ordinal
has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring. Open
ordinal : function (number) {
return number === 1 ? 'er' :
number === 2 ? 'do' :
number === 3 ? 'ro' :
number === 4 ? 'to' :
- 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 server.js
has 387 lines of code (exceeds 250 allowed). Consider refactoring. Open
"use strict";
// APP
var _ = require('lodash');
Similar blocks of code found in 2 locations. Consider refactoring. Open
function stylusRender(fdsFormat, stylusContent){
if(fdsFormat=='source'){
return sourceRenderer('stylus')('source',stylusContent);
}else{
return Promise.resolve().then(function(){
- 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 101.
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
function jadeRender(fdsFormat, jadeContent){
if(fdsFormat=='source'){
return sourceRenderer('jade')('source',jadeContent);
}else{
return Promise.resolve().then(function(){
- 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 101.
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 template
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
template: function(locals, done){
if(locals.directory.match(/\/$/)){
locals.directory=locals.directory.replace(/\/$/,'');
}
var pathParts=locals.directory.split('/');
Function loadFrames
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
function loadFrames(){
var pattern=/^((https?:\/\/)?[-a-z.0-9]+(:\d+)?)\/file(\/|$)/;
actualFrames.forEach(function(frame){
frame.controlTagLateral.textContent='T';
if(!frame.codenautas_info){
Function onload
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
onload:function(text){
if(element.textContent==='...'){
element.textContent='';
}
element.title=text;
Function onload
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
onload:function(e){
var info=JSON.parse(this.responseText);
frame.codenautas_info.originFileName=info.originFileName;
if(frame.codenautas_info.mtime!='ignored' && frame.codenautas_info.mtime<info.mtime){
frame.controlTagLateral.textContent='R';
Function serveConvert
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
var serveConvert=function serveConvert(root, opts, adapter){
if(!adapter){
adapter=function(){ return function(x){ return x; }; };
}
return function(req,res,next){
Consider simplifying this complex logical expression. Open
if(converter && (req.query.fds || converter.auto || converter.others)){
var fileName=root+'/'+req.path;
var exts=[ext].concat(converter.others||[]);
var p=Promise.resolve({pending:true});
var fdsFormat = req.query.fds=='auto' && converter.auto || req.query.fds || converter.auto || 'auto';
Function onload
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
frame.onload=function(){
var insideFrame=false;
try{
insideFrame=pattern.test(frame.contentDocument.URL);
}catch(err){
Avoid deeply nested control flow statements. Open
if(element){
addDirEntryIcon(element,{
icon:response.icon,
value:property,
property:property
Function ajaxSimple
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function ajaxSimple(params){
var ajax = new XMLHttpRequest();
params.onerror=params.onerror||function(err){ alert(err); };
ajax.open(params.method||'get',params.url);
ajax.onload=function(e){
- 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"