Showing 358 of 388 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
async query (key: string, limit: number, lt?: string, gt?: string): Promise<PoolSwap[]> {
return await this.database.query(PoolSwapMapping.index.key_sort, {
partitionKey: key,
limit: limit,
order: SortOrder.DESC,
- Read upRead up
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 98.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
async query (key: string, limit: number, lt?: string, gt?: string): Promise<VaultAuctionBatchHistory[]> {
return await this.database.query(VaultAuctionHistoryMapping.index.vault_auction_history_key_sort, {
partitionKey: key,
limit: limit,
order: SortOrder.DESC,
- Read upRead up
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 98.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
private async cachedGet<T> (field: string, fetch: () => Promise<T>, ttl: number): Promise<T> {
const object = await this.cache.get(`StatsController.${field}`, fetch, { ttl })
return requireValue(object, field)
}
- Read upRead up
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 98.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function run
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Interval(6000)
async run (): Promise<void> {
if (this.vaultId === undefined) {
this.vaultId = await this.client.loan.createVault({
loanSchemeId: 'MIN150',
Function shouldQueryPartitionSortPagination
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function shouldQueryPartitionSortPagination (database: Database): Promise<void> {
const window43 = await database.query(PartitionSortMapping.index.composite_a, {
partitionKey: '1000',
limit: 2,
order: SortOrder.DESC
Function listAccountHistory
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Get('/history')
async listAccountHistory (
@Param('address') address: string,
@Query() query: PaginationQuery): Promise<ApiPagedResponse<AddressHistory>> {
if (address === 'mine') {
Function mapPriceAggregated
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async mapPriceAggregated (block: RawBlock, token: string, currency: string): Promise<OraclePriceAggregated | undefined> {
const oracles = await this.tokenCurrencyMapper.query(`${token}-${currency}`, Number.MAX_SAFE_INTEGER)
const aggregated = {
total: new BigNumber(0),
Similar blocks of code found in 2 locations. Consider refactoring. Open
tokenB: {
id: string
name: string
symbol: string
displaySymbol: string
- Read upRead up
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 97.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
tokenA: {
id: string
name: string
symbol: string
displaySymbol: string
- Read upRead up
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 97.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function put
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
async put<M extends Model> (mapping: ModelMapping<M>, model: M): Promise<void> {
const indexes = Object.values(mapping.index)
const persisted = await this.get(mapping, model.id) as M
if (persisted !== undefined) {
- 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 getStats
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getStats (jsonPath?: string): Promise<LegacyStats | any> {
const stats: StatsData = await this.api.stats.get()
// Fire async requests at the same time and await results
const [
Function shouldQueryWithAscDesc
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function shouldQueryWithAscDesc (database: Database): Promise<void> {
const partitionADesc = await database.query(PartitionMapping.index.partition_a, {
limit: 100,
order: SortOrder.DESC
})
Function fromScript
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function fromScript (script: Script, network: NetworkName): DecodedAddress | undefined {
const p2wpkh = fromScriptP2WPKH(script, network)
if (p2wpkh !== undefined) {
return {
type: AddressType.P2WPKH,
Function getBestPath
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getBestPath (fromTokenId: string, toTokenId: string): Promise<BestSwapPathResult> {
const {
fromToken,
toToken,
paths
Similar blocks of code found in 2 locations. Consider refactoring. Open
async createVault (createVault: CreateVault, changeScript: Script): Promise<TransactionSegWit> {
const creationFee = this.network.name === 'mainnet' ? new BigNumber('2') : new BigNumber('1')
return await super.createDeFiTx(
OP_CODES.OP_DEFI_TX_CREATE_VAULT(createVault),
- Read upRead up
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 94.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
async createVault (createVault: CreateVault, changeScript: Script): Promise<TransactionSegWit> {
const creationFee = this.network.name === 'mainnet' ? new BigNumber('2') : new BigNumber('1')
return await super.createDeFiTx(
OP_CODES.OP_DEFI_TX_CREATE_VAULT(createVault),
- Read upRead up
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 94.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function getCmd
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected getCmd (opts: StartOptions): string[] {
const cmds = [...super.getCmd(opts),
'-regtest=1',
'-jellyfish_regtest=1',
'-txnotokens=0',
Function parse
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
async parse (txn: defid.Transaction): Promise<string[]> {
const result: string[] = []
for (const vin of txn.vin) {
result.push(...(await this.utxo.extractFromVin(vin)))
- 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 getDfTxTransactions
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private getDfTxTransactions (block: RawBlock): Array<DfTxTransaction<any>> {
const transactions: Array<DfTxTransaction<any>> = []
for (let i = 0; i < block.tx.length; i++) {
const txn = block.tx[i]
- 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 invalidate
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
async invalidate (block: RawBlock): Promise<void> {
for (const txn of block.tx) {
const isEvmTx = checkIfEvmTx(txn)
for (const vin of txn.vin) {
- 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"