Function curveDelay
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function curveDelay (curve: PalletReferendaCurve, input: BN, div: BN): BN {
try {
// if divisor is zero, we return the max
if (div.isZero()) {
return BN_BILLION;
Function curveDelay
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
export function curveDelay (curve: PalletReferendaCurve, input: BN, div: BN): BN {
try {
// if divisor is zero, we return the max
if (div.isZero()) {
return BN_BILLION;
- 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 curveThreshold
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function curveThreshold (curve: PalletReferendaCurve, input: BN, div: BN): BN {
// if divisor is zero, we return the max
if (div.isZero()) {
return BN_BILLION;
}
Function getTrackInfo
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function getTrackInfo (api: ApiPromise, specName: string, palletReferenda: string, tracks: TrackDescription[], trackId?: number): TrackInfoExt | undefined {
let info: TrackInfoExt | undefined;
if (tracks && trackId !== undefined && trackId !== -1) {
const originMap = getGovernanceTracks(api, specName, palletReferenda);
- 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 getTrackInfo
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export function getTrackInfo (api: ApiPromise, specName: string, palletReferenda: string, tracks: TrackDescription[], trackId?: number): TrackInfoExt | undefined {
Avoid too many return
statements within this function. Open
return bnMin(
BN_BILLION,
factor
.mul(BN_BILLION)
.div(div)
Avoid too many return
statements within this function. Open
return bnMin(
BN_BILLION,
bnMax(
BN_ZERO,
factor
Function curveThreshold
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function curveThreshold (curve: PalletReferendaCurve, input: BN, div: BN): BN {
// if divisor is zero, we return the max
if (div.isZero()) {
return BN_BILLION;
}
- 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"