Showing 7 of 15 total issues
Function reducePrecision
has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring. Open
Open
private reducePrecision(
numberString: string,
precision = 30,
nonZeroDigits = 4,
round = false,
- Read upRead up
- Create a ticketCreate a ticket
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 index.ts
has 483 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
type Template = 'number' | 'usd' | 'irt' | 'irr' | 'percent';
type Precision = 'auto' | 'high' | 'medium' | 'low';
type Language = 'en' | 'fa';
type OutputFormat = 'plain' | 'html' | 'markdown';
- Create a ticketCreate a ticket
Function format
has 188 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private format(input: string | number): FormattedObject {
let { precision, template } = this.options;
const {
language,
- Create a ticketCreate a ticket
Function reducePrecision
has 183 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private reducePrecision(
numberString: string,
precision = 30,
nonZeroDigits = 4,
round = false,
- Create a ticketCreate a ticket
Function format
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
Open
private format(input: string | number): FormattedObject {
let { precision, template } = this.options;
const {
language,
- Read upRead up
- Create a ticketCreate a ticket
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
Avoid deeply nested control flow statements. Open
Open
if (fractionalZeroStr.length > 0) {
fractionalZeroStr = fractionalZeroStr.substring(
0,
fractionalZeroStr.length - 1
);
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if (language === 'en') {
unitPostfix += '%';
} else {
unitPostfix += !unitPostfix ? '٪' : ' درصد';
}
- Create a ticketCreate a ticket