Showing 15 of 19 total issues
Integer
has 77 functions (exceeds 20 allowed). Consider refactoring. Open
export class Integer {
constructor(base, is_negative, limbs) {
this._base = base;
this._is_negative = is_negative;
this._limbs = limbs;
File Integer.js
has 434 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {DEFAULT_DISPLAY_BASE} from './DEFAULT_DISPLAY_BASE.js';
import {ZeroDivisionError} from './ZeroDivisionError.js';
import {ValueError} from '@aureooms/js-error';
Function egcd
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
egcd(other) {
const r = this._base;
const a = this._limbs;
const b = other._limbs_in_base(r);
const [
Function from
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
from(object, base = undefined, is_negative = 0) {
if (object === null || object === undefined) return this.$0();
switch (object.constructor.prototype) {
case Number.prototype:
- 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 divmod
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
divmod(other) {
if (other.iszero()) throw new ZeroDivisionError('Integer division by zero'); // Optimize
const quotient_is_negative = this._is_negative ^ other._is_negative;
const r = this._base;
- 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 from
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
from(object, base = undefined, is_negative = 0) {
if (object === null || object === undefined) return this.$0();
switch (object.constructor.prototype) {
case Number.prototype:
Function divmod
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
divmod(other) {
if (other.iszero()) throw new ZeroDivisionError('Integer division by zero'); // Optimize
const quotient_is_negative = this._is_negative ^ other._is_negative;
const r = this._base;
Function cmp
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
cmp(other) {
// TODO optimize with _trim_positive
if (this.iszero()) {
if (other.iszero()) return 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 from_string
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
from_string(string, base = 10, is_negative = 0) {
if (string.length === 0)
throw new ValueError(
'IntegerRing#from_string cannot parse empty 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"
Further reading
Avoid too many return
statements within this function. Open
return this._is_negative === 0
? cmp(a, 0, a.length, b, 0, b.length)
: cmp(b, 0, b.length, a, 0, a.length);
Avoid too many return
statements within this function. Open
return new Integer(
object._base,
object._is_negative ^ is_negative,
object._limbs,
);
Avoid too many return
statements within this function. Open
return this.from_number(Number(object), is_negative);
Avoid too many return
statements within this function. Open
if (this._is_negative > other._is_negative) return 1;
Avoid too many return
statements within this function. Open
return new Integer(r, this._is_negative, c);
Function sub
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
sub(other) {
if (this._is_negative !== other._is_negative) {
return other._is_negative
? this.add(other.opposite())
: this.opposite().add(other).opposite();
- 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"