Showing 13 of 15 total issues
Function renameRequire
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
function renameRequire(ast, filePath, opts) {
var aliasMap = {},
addAlias = function(alias) { if (alias) { _.assign(aliasMap, alias); } },
delAlias = function(alias) { if (alias) { aliasMap = _.omit(aliasMap, _.keys(alias)); } };
- 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 removeExport
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
function removeExport(ast, filePath, opts) {
var bodyNodes = ast.body, node, obj, prop, i, statCount = 0, exportCount = 0, exportMember, exportGlobal = false;
var exp = rename(filePath, opts);
- 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 findAllRequiredFile
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
function findAllRequiredFile(filePath) {
var ast = helper.getFileAST(filePath),
result = [];
//require('fs').writeFile(filePath.replace(/\.js$/, '.json'), JSON.stringify(ast, null, 2));
- 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 removeExport
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
function removeExport(ast, filePath, opts) {
var bodyNodes = ast.body, node, obj, prop, i, statCount = 0, exportCount = 0, exportMember, exportGlobal = false;
var exp = rename(filePath, opts);
Function removeRequire
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function removeRequire(ast, filePath, opts) {
var removePaths = [];
estraverse.traverse(ast, {
enter: function(node, parent) {
if (node.type === 'VariableDeclaration') {
- 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 renameRequire
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function renameRequire(ast, filePath, opts) {
var aliasMap = {},
addAlias = function(alias) { if (alias) { _.assign(aliasMap, alias); } },
delAlias = function(alias) { if (alias) { aliasMap = _.omit(aliasMap, _.keys(alias)); } };
Function removeRequire
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function removeRequire(ast, filePath, opts) {
var removePaths = [];
estraverse.traverse(ast, {
enter: function(node, parent) {
if (node.type === 'VariableDeclaration') {
Function findAllRequiredFile
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function findAllRequiredFile(filePath) {
var ast = helper.getFileAST(filePath),
result = [];
//require('fs').writeFile(filePath.replace(/\.js$/, '.json'), JSON.stringify(ast, null, 2));
Function exports
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(filePath, opts) {
opts = _.assign({
global: 'G',
rename: null,
transform: null, // should be function
Function enter
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
enter: function(node, parent) {
addAlias(node._alias);
var i, id, param, t;
// 函数中的参数如果包含有 alias 的话,则之后出现的 alias 全部忽略
Avoid deeply nested control flow statements. Open
if (!exportMember) {
exportGlobal = true;
}
Function exports
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function(filePath, opts) {
opts = _.assign({
global: 'G',
rename: null,
transform: null, // should be function
- 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 rename
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function rename(filePath, opts) {
var res;
if (opts.rename && typeof opts.rename === 'function') {
res = opts.rename(filePath);
if (typeof res === 'string') {
- 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"