Showing 7 of 7 total issues
Function writtenNumber
has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring. Open
Open
function writtenNumber(n, options) {
options = options || {};
options = util.defaults(options, writtenNumber.defaults);
if (n < 0) {
- 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 writtenNumber
has 130 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function writtenNumber(n, options) {
options = options || {};
options = util.defaults(options, writtenNumber.defaults);
if (n < 0) {
Consider simplifying this complex logical expression. Open
Open
} else if (unit.few && (r > 1 && r < 5 || unit.useFewEnding && r % 10 > 1 && r % 10 < 5
&& (!unit.avoidEndingRules || unit.avoidEndingRules.indexOf(r) < 0))) {
str = unit.few;
} else {
str = unit.plural && (!unit.avoidInNumberPlural || !m)
Function exports
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function (grunt) {
grunt.initConfig({
clean: {
dist: [
'dist'
Function handleSmallerThan100
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function handleSmallerThan100(n, language, unit, baseCardinals, alternativeBaseCardinals, options) {
Avoid too many return
statements within this function. Open
Open
return handleSmallerThan100(n, language, unit, baseCardinals, alternativeBaseCardinals, options);
Avoid too many return
statements within this function. Open
Open
return result;