kleros/kleros-v2

View on GitHub
contracts/deploy/00-home-chain-arbitration-university.ts

Summary

Maintainability
C
1 day
Test Coverage

Function deployArbitration has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers, deployments, getNamedAccounts, getChainId } = hre;
  const { deploy } = deployments;
  const { AddressZero } = hre.ethers.constants;

Severity: Major
Found in contracts/deploy/00-home-chain-arbitration-university.ts - About 2 hrs to fix

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

  try {
    await changeCurrencyRate(core, pnk.address, true, 12225583, 12);
    await changeCurrencyRate(core, dai.address, true, 60327783, 11);
    await changeCurrencyRate(core, weth.address, true, 1, 1);
  } catch (e) {
Severity: Major
Found in contracts/deploy/00-home-chain-arbitration-university.ts and 1 other location - About 2 hrs to fix
contracts/deploy/00-home-chain-arbitration.ts on lines 94..100

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

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

  if (!klerosCoreAddress) {
    const nonce = await ethers.provider.getTransactionCount(deployer);
    klerosCoreAddress = getContractAddress(deployer, nonce + 3); // deployed on the 4th tx (nonce+3): SortitionModule Impl tx, SortitionModule Proxy tx, KlerosCore Impl tx, KlerosCore Proxy tx
    console.log("calculated future KlerosCoreUniversity address for nonce %d: %s", nonce + 3, klerosCoreAddress);
  }
Severity: Major
Found in contracts/deploy/00-home-chain-arbitration-university.ts and 2 other locations - About 1 hr to fix
contracts/deploy/00-home-chain-arbitration-neo.ts on lines 52..56
contracts/deploy/00-home-chain-arbitration.ts on lines 50..54

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

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

  if (currentCore !== klerosCore.address) {
    console.log(`disputeKit.changeCore(${klerosCore.address})`);
    await disputeKitContract.changeCore(klerosCore.address);
  }
Severity: Major
Found in contracts/deploy/00-home-chain-arbitration-university.ts and 1 other location - About 1 hr to fix
contracts/deploy/00-home-chain-arbitration-neo.ts on lines 102..105

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

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

deployArbitration.skip = async ({ network }) => {
  return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
};
Severity: Major
Found in contracts/deploy/00-home-chain-arbitration-university.ts and 15 other locations - About 40 mins to fix
contracts/deploy/00-ethereum-pnk.ts on lines 27..29
contracts/deploy/00-home-chain-arbitrable.ts on lines 49..51
contracts/deploy/00-home-chain-arbitration-neo.ts on lines 132..134
contracts/deploy/00-home-chain-arbitration-ruler.ts on lines 77..79
contracts/deploy/00-home-chain-arbitration.ts on lines 104..106
contracts/deploy/00-home-chain-pnk-faucet.ts on lines 37..39
contracts/deploy/00-rng.ts on lines 42..44
contracts/deploy/00-transaction-batcher.ts on lines 22..24
contracts/deploy/01-foreign-gateway-on-ethereum.ts on lines 51..53
contracts/deploy/01-foreign-gateway-on-gnosis.ts on lines 55..57
contracts/deploy/04-foreign-arbitrable.ts on lines 62..64
contracts/deploy/04-klerosliquid-to-v2-gnosis.ts on lines 146..148
contracts/deploy/fix1148.ts on lines 53..55
contracts/deploy/upgrade-kleros-core.ts on lines 46..48
contracts/deploy/upgrade-sortition-module.ts on lines 39..41

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

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