gothands / contracts

0 stars 1 forks source link

Static analysis via slither and solhint #2

Closed juztamau5 closed 1 year ago

juztamau5 commented 1 year ago

Description

This PR adds static analysis via slither and solhint. A GitHub action is provided to run these tools on CI.

Related PRs

How has this been tested?

Both tests currently fail.

Slither:

$ yarn slither
yarn run v1.22.19
$ slither .
'npx hardhat clean' running (wd: /home/garrett/Documents/handsy-contracts)
'npx hardhat clean --global' running (wd: /home/garrett/Documents/handsy-contracts)
'npx hardhat compile --force' running
Downloading compiler 0.8.17
Generating typings for: 14 artifacts in dir: typechain-types for target: ethers-v6
Successfully generated 44 typings!
Compiled 14 Solidity files successfully

Warning: ...

INFO:Slither:. analyzed (14 contracts with 85 detectors), 54 result(s) found
error Command failed with exit code 255.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Solhint:

$ yarn solhint
yarn run v1.22.19
$ solhint 'contracts/**/*.sol' --max-warnings 0

contracts/Affiliate.sol
  101:2  error  Line length must be no more than 120 but current length is 128  max-line-length
  132:2  error  Line length must be no more than 120 but current length is 138  max-line-length

contracts/Bank.sol
   7:1  error  Unexpected import of console file                               no-console
  26:2  error  Line length must be no more than 120 but current length is 168  max-line-length
  42:2  error  Line length must be no more than 120 but current length is 166  max-line-length
  75:2  error  Line length must be no more than 120 but current length is 212  max-line-length
  76:9  error  Unexpected console statement                                    no-console
  77:9  error  Unexpected console statement                                    no-console
  78:9  error  Unexpected console statement                                    no-console
  79:9  error  Unexpected console statement                                    no-console
  80:9  error  Unexpected console statement                                    no-console
  81:9  error  Unexpected console statement                                    no-console
  85:2  error  Line length must be no more than 120 but current length is 133  max-line-length

contracts/Hands.sol
    5:1  error  Unexpected import of console file                               no-console
   98:9  error  Unexpected console statement                                    no-console
  186:2  error  Line length must be no more than 120 but current length is 173  max-line-length

contracts/interfaces/IAffiliate.sol
  40:2  error  Line length must be no more than 120 but current length is 121  max-line-length
  49:2  error  Line length must be no more than 120 but current length is 139  max-line-length

contracts/Staking.sol
  75:2  error  Line length must be no more than 120 but current length is 126  max-line-length

✖ 19 problems (19 errors, 0 warnings)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
juztamau5 commented 1 year ago

Rebased after merging https://github.com/gothands/contracts/pull/1