XYOracleNetwork/clients

View on GitHub
packages/cli/src/command/commands/module/discover.ts

Summary

Maintainability
B
5 hrs
Test Coverage

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

export const handler = async (argv: ModuleArguments) => {
  const { verbose } = argv
  try {
    const mod = await getModuleFromArgs(argv)
    const result = await mod.state()
Severity: Major
Found in packages/cli/src/command/commands/module/discover.ts and 7 other locations - About 4 hrs to fix
packages/cli/src/command/commands/module/describe.ts on lines 16..26
packages/cli/src/command/commands/module/previousHash.ts on lines 16..26
packages/cli/src/command/commands/node/describe.ts on lines 18..28
packages/cli/src/command/commands/node/discover.ts on lines 15..25
packages/cli/src/command/commands/node/previousHash.ts on lines 15..25
packages/cli/src/command/commands/archivist/describe.ts on lines 15..25
packages/cli/src/command/commands/archivist/discover.ts on lines 15..25

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 118.

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 4 locations. Consider refactoring.
Open

export const builder: CommandBuilder = (yargs: Argv) =>
  yargs.usage('Usage: $0 module discover <address>').positional('address', { demandOption: true, type: 'string' })
Severity: Major
Found in packages/cli/src/command/commands/module/discover.ts and 3 other locations - About 55 mins to fix
packages/cli/src/command/commands/module/describe.ts on lines 11..12
packages/cli/src/command/commands/module/previousHash.ts on lines 11..12
packages/cli/src/command/commands/module/queries.ts on lines 11..12

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 54.

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 21 locations. Consider refactoring.
Open

const mod: CommandModule<EmptyObject, ModuleArguments> = {
  aliases,
  command,
  deprecated,
  describe,
Severity: Major
Found in packages/cli/src/command/commands/module/discover.ts and 20 other locations - About 40 mins to fix
packages/cli/src/command/commands/module/describe.ts on lines 28..34
packages/cli/src/command/commands/module/previousHash.ts on lines 28..34
packages/cli/src/command/commands/module/queries.ts on lines 28..34
packages/cli/src/command/commands/node/describe.ts on lines 30..36
packages/cli/src/command/commands/node/describe/address.ts on lines 24..30
packages/cli/src/command/commands/node/describe/children.ts on lines 35..41
packages/cli/src/command/commands/node/describe/queries.ts on lines 26..32
packages/cli/src/command/commands/node/discover.ts on lines 27..33
packages/cli/src/command/commands/node/previousHash.ts on lines 27..33
packages/cli/src/command/commands/node/start.ts on lines 59..65
packages/cli/src/command/commands/node/stop.ts on lines 33..39
packages/cli/src/command/commands/archivist.ts on lines 33..39
packages/cli/src/command/commands/archivist/describe.ts on lines 27..33
packages/cli/src/command/commands/archivist/discover.ts on lines 27..33
packages/cli/src/command/commands/archivist/get.ts on lines 36..42
packages/cli/src/command/commands/archivist/insert.ts on lines 27..33
packages/cli/src/command/commands/config/show.ts on lines 42..48
packages/cli/src/command/commands/diviner.ts on lines 33..39
packages/cli/src/command/commands/module.ts on lines 31..37
packages/cli/src/command/commands/node.ts on lines 31..37

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 48.

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