synapsecns/sanguine

View on GitHub
packages/rest-api/src/routes/bridgeTxInfoRoute.ts

Summary

Maintainability
D
1 day
Test Coverage

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    check('amount')
      .exists()
      .withMessage('amount is required')
      .isNumeric()
      .custom((value, { req }) => {
Severity: Major
Found in packages/rest-api/src/routes/bridgeTxInfoRoute.ts and 2 other locations - About 3 hrs to fix
packages/rest-api/src/routes/bridgeRoute.ts on lines 247..260
packages/rest-api/src/routes/swapRoute.ts on lines 183..196

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 96.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 10 locations. Consider refactoring.
Open

    check('fromToken')
      .exists()
      .withMessage('fromToken is required')
      .custom((value) => isTokenAddress(value))
      .withMessage('Invalid fromToken address')
Severity: Major
Found in packages/rest-api/src/routes/bridgeTxInfoRoute.ts and 9 other locations - About 2 hrs to fix
packages/rest-api/src/routes/bridgeLimitsRoute.ts on lines 114..122
packages/rest-api/src/routes/bridgeLimitsRoute.ts on lines 123..131
packages/rest-api/src/routes/bridgeRoute.ts on lines 229..237
packages/rest-api/src/routes/bridgeRoute.ts on lines 238..246
packages/rest-api/src/routes/bridgeTxInfoRoute.ts on lines 158..166
packages/rest-api/src/routes/swapRoute.ts on lines 165..173
packages/rest-api/src/routes/swapRoute.ts on lines 174..182
packages/rest-api/src/routes/swapTxInfoRoute.ts on lines 128..136
packages/rest-api/src/routes/swapTxInfoRoute.ts on lines 137..145

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 88.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 10 locations. Consider refactoring.
Open

    check('toToken')
      .exists()
      .withMessage('toToken is required')
      .custom((value) => isTokenAddress(value))
      .withMessage('Invalid toToken address')
Severity: Major
Found in packages/rest-api/src/routes/bridgeTxInfoRoute.ts and 9 other locations - About 2 hrs to fix
packages/rest-api/src/routes/bridgeLimitsRoute.ts on lines 114..122
packages/rest-api/src/routes/bridgeLimitsRoute.ts on lines 123..131
packages/rest-api/src/routes/bridgeRoute.ts on lines 229..237
packages/rest-api/src/routes/bridgeRoute.ts on lines 238..246
packages/rest-api/src/routes/bridgeTxInfoRoute.ts on lines 149..157
packages/rest-api/src/routes/swapRoute.ts on lines 165..173
packages/rest-api/src/routes/swapRoute.ts on lines 174..182
packages/rest-api/src/routes/swapTxInfoRoute.ts on lines 128..136
packages/rest-api/src/routes/swapTxInfoRoute.ts on lines 137..145

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 88.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 3 locations. Consider refactoring.
Open

    check()
      .custom((_value, { req }) => {
        const { fromChain, toChain, fromToken, toToken } = req.query

        return validateRouteExists(fromChain, fromToken, toChain, toToken)
Severity: Major
Found in packages/rest-api/src/routes/bridgeTxInfoRoute.ts and 2 other locations - About 2 hrs to fix
packages/rest-api/src/routes/bridgeLimitsRoute.ts on lines 132..138
packages/rest-api/src/routes/bridgeRoute.ts on lines 261..267

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 75.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 10 locations. Consider refactoring.
Open

    check('toChain')
      .exists()
      .withMessage('toChain is required')
      .isNumeric()
      .custom((value) => CHAINS_ARRAY.some((c) => c.id === Number(value)))
Severity: Major
Found in packages/rest-api/src/routes/bridgeTxInfoRoute.ts and 9 other locations - About 1 hr to fix
packages/rest-api/src/routes/bridgeLimitsRoute.ts on lines 102..107
packages/rest-api/src/routes/bridgeLimitsRoute.ts on lines 108..113
packages/rest-api/src/routes/bridgeRoute.ts on lines 217..222
packages/rest-api/src/routes/bridgeRoute.ts on lines 223..228
packages/rest-api/src/routes/bridgeTxInfoRoute.ts on lines 137..142
packages/rest-api/src/routes/bridgeTxStatusRoute.ts on lines 120..125
packages/rest-api/src/routes/destinationTokensRoute.ts on lines 103..108
packages/rest-api/src/routes/swapRoute.ts on lines 159..164
packages/rest-api/src/routes/swapTxInfoRoute.ts on lines 122..127

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 71.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 10 locations. Consider refactoring.
Open

    check('fromChain')
      .exists()
      .withMessage('fromChain is required')
      .isNumeric()
      .custom((value) => CHAINS_ARRAY.some((c) => c.id === Number(value)))
Severity: Major
Found in packages/rest-api/src/routes/bridgeTxInfoRoute.ts and 9 other locations - About 1 hr to fix
packages/rest-api/src/routes/bridgeLimitsRoute.ts on lines 102..107
packages/rest-api/src/routes/bridgeLimitsRoute.ts on lines 108..113
packages/rest-api/src/routes/bridgeRoute.ts on lines 217..222
packages/rest-api/src/routes/bridgeRoute.ts on lines 223..228
packages/rest-api/src/routes/bridgeTxInfoRoute.ts on lines 143..148
packages/rest-api/src/routes/bridgeTxStatusRoute.ts on lines 120..125
packages/rest-api/src/routes/destinationTokensRoute.ts on lines 103..108
packages/rest-api/src/routes/swapRoute.ts on lines 159..164
packages/rest-api/src/routes/swapTxInfoRoute.ts on lines 122..127

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 71.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

There are no issues that match your filters.

Category
Status