src/scval.js
Function nativeToScVal
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
Open
export function nativeToScVal(val, opts = {}) {
switch (typeof val) {
case 'object':
if (val === null) {
return xdr.ScVal.scvVoid();
- 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 nativeToScVal
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function nativeToScVal(val, opts = {}) {
switch (typeof val) {
case 'object':
if (val === null) {
return xdr.ScVal.scvVoid();
Function scValToNative
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function scValToNative(scv) {
// we use the verbose xdr.ScValType.<type>.value form here because it's faster
// than string comparisons and the underlying constants never need to be
// updated
switch (scv.switch().value) {
Function scValToNative
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
export function scValToNative(scv) {
// we use the verbose xdr.ScValType.<type>.value form here because it's faster
// than string comparisons and the underlying constants never need to be
// updated
switch (scv.switch().value) {
- 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
Open
return xdr.ScVal.scvMap(
Object.entries(val).map(([k, v]) => {
// the type can be specified with an entry for the key and the value,
// e.g. val = { 'hello': 1 } and opts.type = { hello: [ 'symbol',
// 'u128' ]} or you can use `null` for the default interpretation
Avoid too many return
statements within this function. Open
Open
return new ScInt(val, { type: opts?.type }).toScVal();
Avoid too many return
statements within this function. Open
Open
return xdr.ScVal.scvVec(val.map((v) => nativeToScVal(v, opts)));
Avoid too many return
statements within this function. Open
Open
return new XdrLargeInt(optType, val).toScVal();