enzymefinance / protocol

Enzyme Protocol Implementation
https://enzyme.finance
GNU General Public License v3.0
375 stars 156 forks source link

chore: prettier and solhint formatting and linting #1028

Closed fubhy closed 4 years ago

fubhy commented 4 years ago

@SeanJCasey This uses the latest version of solhint which works much better with prettier than the version coming with buidler (outdated).

I ran the prettier formatter on all the contracts and fixed 2 comment-positioning errors in SharesRequester and ValueInterpreter (comments between if/else statement brackets).

Solhint then only reported errors regarding the used pragma statements which I changed to 0.6.8 in some of the dependencies where it was set to an earlier version.

Now, solhint does not report any errors anymore (just warnings) so I also added it to .travis.yml. Warnings will still allow the build to pass but if any new errors are introduced it wont.

Please check the formatting of the contracts with prettier and if you feel like we should try to configure it differently to match our style better (there are only very limited options to do so though).

fubhy commented 4 years ago

These are the current warnings. You'll notice that there are many reason-string warnings that are likely going to go away once we use error codes instead (if that's still planned). If not, we could also just adapt the configuration to remove reason-string from the rules for now or make it less strict.

tests/contracts/integratees/MockKyberIntegratee.sol
  10:5  warning  Code contains empty blocks  no-empty-blocks
tests/contracts/integratees/utils/MockIntegrateeBase.sol
  20:5   warning  Code contains empty blocks             no-empty-blocks
  59:13  warning  Error message for require is too long  reason-string
  60:13  warning  Error message for require is too long  reason-string
  72:13  warning  Error message for require is too long  reason-string
  73:13  warning  Error message for require is too long  reason-string
tests/contracts/priceSources/MockKyberPriceSource.sol
  12:5  warning  Code contains empty blocks  no-empty-blocks
tests/contracts/utils/NormalizedRateProviderBase.sol
  10:30  warning  Variable name must be in mixedCase  var-name-mixedcase
tests/contracts/utils/RateProviderBase.sol
  15:9  warning  Error message for require is too long  reason-string
  49:9  warning  Error message for require is too long  reason-string
  53:9  warning  Error message for require is too long  reason-string
tests/contracts/WETH.sol
  27:9   warning  Provide an error message for require  reason-string
  52:9   warning  Provide an error message for require  reason-string
  55:13  warning  Provide an error message for require  reason-string
contracts/dependencies/DSGuard.sol
  16:5  warning  Explicitly mark visibility of state  state-visibility
contracts/dependencies/DSMath.sol
  47:5  warning  Explicitly mark visibility of state  state-visibility
  48:5  warning  Explicitly mark visibility of state  state-visibility
contracts/dependencies/SafeMath.sol
  20:9  warning  Provide an error message for require  reason-string
  29:9  warning  Provide an error message for require  reason-string
  40:9  warning  Provide an error message for require  reason-string
  51:9  warning  Provide an error message for require  reason-string
  61:9  warning  Provide an error message for require  reason-string
contracts/dependencies/token/StandardToken.sol
   17:5  warning  Explicitly mark visibility of state   state-visibility
   19:5  warning  Explicitly mark visibility of state   state-visibility
   21:5  warning  Explicitly mark visibility of state   state-visibility
   55:9  warning  Provide an error message for require  reason-string
   56:9  warning  Provide an error message for require  reason-string
   90:9  warning  Provide an error message for require  reason-string
   91:9  warning  Provide an error message for require  reason-string
   92:9  warning  Provide an error message for require  reason-string
  153:9  warning  Provide an error message for require  reason-string
  166:9  warning  Provide an error message for require  reason-string
  167:9  warning  Provide an error message for require  reason-string
  182:9  warning  Provide an error message for require  reason-string
contracts/dependencies/TokenUser.sol
  21:9  warning  Error message for require is too long  reason-string
  48:9  warning  Error message for require is too long  reason-string
  64:9  warning  Error message for require is too long  reason-string
contracts/dependencies/WETH.sol
  26:9   warning  Provide an error message for require  reason-string
  51:9   warning  Provide an error message for require  reason-string
  54:13  warning  Provide an error message for require  reason-string
contracts/engine/AmguConsumer.sol
  18:22  warning  Variable name must be in mixedCase     var-name-mixedcase
  34:9   warning  Error message for require is too long  reason-string
  43:9   warning  Error message for require is too long  reason-string
  61:13  warning  Error message for require is too long  reason-string
  71:9   warning  Error message for require is too long  reason-string
contracts/engine/Engine.sol
   46:20  warning  Avoid to make time-based decisions in your business logic  not-rely-on-time
   85:9   warning  Error message for require is too long                      reason-string
  112:17  warning  Avoid to make time-based decisions in your business logic  not-rely-on-time
  114:20  warning  Avoid to make time-based decisions in your business logic  not-rely-on-time
  138:9   warning  Error message for require is too long                      reason-string
contracts/factory/FundFactory.sol
   96:9  warning  Error message for require is too long  reason-string
   97:9  warning  Error message for require is too long  reason-string
  101:9  warning  Error message for require is too long  reason-string
  212:9  warning  Error message for require is too long  reason-string
  216:9  warning  Error message for require is too long  reason-string
  220:9  warning  Error message for require is too long  reason-string
  221:9  warning  Error message for require is too long  reason-string
  235:9  warning  Error message for require is too long  reason-string
  254:9  warning  Error message for require is too long  reason-string
  279:9  warning  Error message for require is too long  reason-string
  295:9  warning  Error message for require is too long  reason-string
contracts/fund/fees/FeeManager.sol
  41:13  warning  Error message for require is too long  reason-string
  44:13  warning  Error message for require is too long  reason-string
  76:21  warning  Code contains empty blocks             no-empty-blocks
contracts/fund/fees/ManagementFee.sol
  12:20  warning  Variable name must be in mixedCase                         var-name-mixedcase
  22:38  warning  Avoid to make time-based decisions in your business logic  not-rely-on-time
  36:9   warning  Variable "feePeriod" is unused                             no-unused-vars
  37:9   warning  Variable "denominationAsset" is unused                     no-unused-vars
  39:9   warning  Provide an error message for require                       reason-string
  41:38  warning  Avoid to make time-based decisions in your business logic  not-rely-on-time
  45:38  warning  Avoid to make time-based decisions in your business logic  not-rely-on-time
contracts/fund/fees/PerformanceFee.sol
  34:38  warning  Avoid to make time-based decisions in your business logic  not-rely-on-time
  35:38  warning  Avoid to make time-based decisions in your business logic  not-rely-on-time
  57:37  warning  Avoid to make time-based decisions in your business logic  not-rely-on-time
  59:37  warning  Avoid to make time-based decisions in your business logic  not-rely-on-time
  66:9   warning  Error message for require is too long                      reason-string
  74:9   warning  Error message for require is too long                      reason-string
  78:38  warning  Avoid to make time-based decisions in your business logic  not-rely-on-time
contracts/fund/hub/Hub.sol
  22:29  warning  Variable name must be in mixedCase     var-name-mixedcase
  23:19  warning  Variable name must be in mixedCase     var-name-mixedcase
  27:29  warning  Variable name must be in mixedCase     var-name-mixedcase
  28:29  warning  Variable name must be in mixedCase     var-name-mixedcase
  37:9   warning  Error message for require is too long  reason-string
  55:9   warning  Error message for require is too long  reason-string
  64:9   warning  Error message for require is too long  reason-string
  73:9   warning  Error message for require is too long  reason-string
  99:9   warning  Error message for require is too long  reason-string
contracts/fund/hub/IHub.sol
  11:5  warning  Function name must be in mixedCase  func-name-mixedcase
  13:5  warning  Function name must be in mixedCase  func-name-mixedcase
  17:5  warning  Function name must be in mixedCase  func-name-mixedcase
contracts/fund/hub/ISpoke.sol
  8:5  warning  Function name must be in mixedCase  func-name-mixedcase
contracts/fund/hub/Spoke.sol
  20:29  warning  Variable name must be in mixedCase     var-name-mixedcase
  23:9   warning  Error message for require is too long  reason-string
  28:9   warning  Error message for require is too long  reason-string
contracts/fund/policies/compliance/UserWhitelist.sol
  11:65  warning  Code contains empty blocks             no-empty-blocks
  38:9   warning  Error message for require is too long  reason-string
contracts/fund/policies/PolicyManager.sol
  20:50  warning  Code contains empty blocks             no-empty-blocks
  30:9   warning  Error message for require is too long  reason-string
  32:9   warning  Error message for require is too long  reason-string
  33:9   warning  Error message for require is too long  reason-string
  42:13  warning  Error message for require is too long  reason-string
  46:13  warning  Error message for require is too long  reason-string
contracts/fund/policies/risk-management/AssetBlacklist.sol
  12:65  warning  Code contains empty blocks  no-empty-blocks
contracts/fund/policies/risk-management/AssetWhitelist.sol
  12:65  warning  Code contains empty blocks  no-empty-blocks
contracts/fund/policies/risk-management/MaxConcentration.sol
  20:65  warning  Code contains empty blocks             no-empty-blocks
  30:9   warning  Error message for require is too long  reason-string
  31:9   warning  Error message for require is too long  reason-string
  74:13  warning  Error message for require is too long  reason-string
contracts/fund/policies/risk-management/MaxPositions.sol
  15:65  warning  Code contains empty blocks             no-empty-blocks
  25:9   warning  Error message for require is too long  reason-string
contracts/fund/policies/risk-management/PriceTolerance.sol
  20:65  warning  Code contains empty blocks             no-empty-blocks
  30:9   warning  Error message for require is too long  reason-string
  92:13  warning  Error message for require is too long  reason-string
contracts/fund/policies/utils/AddressListPolicyMixin.sol
  16:5   warning  Explicitly mark visibility of state    state-visibility
  43:9   warning  Error message for require is too long  reason-string
  46:13  warning  Error message for require is too long  reason-string
  57:9   warning  Error message for require is too long  reason-string
  60:13  warning  Error message for require is too long  reason-string
contracts/fund/policies/utils/PolicyBase.sol
  14:20  warning  Variable name must be in mixedCase     var-name-mixedcase
  17:9   warning  Error message for require is too long  reason-string
  28:9   warning  Error message for revert is too long   reason-string
contracts/fund/shares/IShares.sol
  13:5  warning  Function name must be in mixedCase  func-name-mixedcase
contracts/fund/shares/Shares.sol
   24:39  warning  Variable name must be in mixedCase     var-name-mixedcase
   27:9   warning  Error message for require is too long  reason-string
   39:9   warning  Error message for require is too long  reason-string
   65:9   warning  Error message for require is too long  reason-string
   79:9   warning  Error message for require is too long  reason-string
  128:13  warning  Error message for require is too long  reason-string
  157:9   warning  Error message for require is too long  reason-string
  158:9   warning  Error message for require is too long  reason-string
  165:9   warning  Error message for require is too long  reason-string
  181:71  warning  Code contains empty blocks             no-empty-blocks
  181:80  warning  Code contains empty blocks             no-empty-blocks
  186:17  warning  Error message for require is too long  reason-string
  192:21  warning  Error message for revert is too long   reason-string
contracts/fund/vault/Vault.sol
  103:13  warning  Error message for require is too long  reason-string
  112:9   warning  Error message for require is too long  reason-string
  165:13  warning  Error message for require is too long  reason-string
  179:13  warning  Error message for require is too long  reason-string
  183:13  warning  Error message for require is too long  reason-string
  199:51  warning  Avoid to use low level calls           avoid-low-level-calls
  237:9   warning  Error message for require is too long  reason-string
  241:9   warning  Error message for require is too long  reason-string
  254:9   warning  Error message for require is too long  reason-string
  258:9   warning  Error message for require is too long  reason-string
  262:9   warning  Error message for require is too long  reason-string
  263:9   warning  Error message for require is too long  reason-string
  268:13  warning  Error message for require is too long  reason-string
  364:13  warning  Error message for require is too long  reason-string
  370:13  warning  Error message for require is too long  reason-string
  388:13  warning  Error message for require is too long  reason-string
contracts/integrations/adapters/EngineAdapter.sol
  12:30  warning  Variable name must be in mixedCase     var-name-mixedcase
  19:32  warning  Code contains empty blocks             no-empty-blocks
  63:13  warning  Error message for revert is too long   reason-string
  78:9   warning  Error message for require is too long  reason-string
contracts/integrations/adapters/KyberAdapter.sol
  13:30  warning  Variable name must be in mixedCase     var-name-mixedcase
  20:32  warning  Code contains empty blocks             no-empty-blocks
  66:13  warning  Error message for revert is too long   reason-string
  86:9   warning  Error message for require is too long  reason-string
  87:9   warning  Error message for require is too long  reason-string
  88:9   warning  Error message for require is too long  reason-string
  92:9   warning  Error message for require is too long  reason-string
  93:9   warning  Error message for require is too long  reason-string
contracts/integrations/adapters/UniswapV2Adapter.sol
  11:30  warning  Variable name must be in mixedCase                         var-name-mixedcase
  60:13  warning  Error message for revert is too long                       reason-string
  80:9   warning  Error message for require is too long                      reason-string
  81:9   warning  Error message for require is too long                      reason-string
  90:17  warning  Avoid to make time-based decisions in your business logic  not-rely-on-time
contracts/integrations/adapters/ZeroExV2Adapter.sol
   14:30  warning  Variable name must be in mixedCase                                 var-name-mixedcase
   88:13  warning  Error message for revert is too long                               reason-string
  107:9   warning  Error message for require is too long                              reason-string
  170:9   warning  Avoid to use inline assembly. It is acceptable only in rare cases  no-inline-assembly
  185:9   warning  Avoid to use inline assembly. It is acceptable only in rare cases  no-inline-assembly
contracts/integrations/adapters/ZeroExV3Adapter.sol
   14:30  warning  Variable name must be in mixedCase                                 var-name-mixedcase
   97:13  warning  Error message for revert is too long                               reason-string
  117:9   warning  Error message for require is too long                              reason-string
  121:9   warning  Error message for require is too long                              reason-string
  198:9   warning  Avoid to use inline assembly. It is acceptable only in rare cases  no-inline-assembly
  213:9   warning  Avoid to use inline assembly. It is acceptable only in rare cases  no-inline-assembly
contracts/integrations/interfaces/IZeroExV2.sol
  35:5  warning  Function name must be in mixedCase  func-name-mixedcase
contracts/integrations/utils/AdapterBase.sol
  20:30  warning  Variable name must be in mixedCase     var-name-mixedcase
  34:9   warning  Error message for require is too long  reason-string
  43:13  warning  Error message for require is too long  reason-string
  47:13  warning  Error message for require is too long  reason-string
  61:13  warning  Error message for require is too long  reason-string
contracts/prices/primitives/IPriceSource.sol
  25:5  warning  Function name must be in mixedCase  func-name-mixedcase
contracts/prices/primitives/KyberPriceFeed.sol
   28:30  warning  Variable name must be in mixedCase                         var-name-mixedcase
   29:30  warning  Variable name must be in mixedCase                         var-name-mixedcase
   82:9   warning  Error message for require is too long                      reason-string
   83:9   warning  Error message for require is too long                      reason-string
  155:9   warning  Error message for require is too long                      reason-string
  161:9   warning  Error message for require is too long                      reason-string
  181:13  warning  Error message for require is too long                      reason-string
  190:22  warning  Avoid to make time-based decisions in your business logic  not-rely-on-time
  258:24  warning  Avoid to make time-based decisions in your business logic  not-rely-on-time
contracts/prices/ValueInterpreter.sol
  15:5   warning  Explicitly mark visibility of state  state-visibility
  15:13  warning  Variable name must be in mixedCase   var-name-mixedcase
contracts/registry/IRegistry.sol
  35:5  warning  Function name must be in mixedCase  func-name-mixedcase
contracts/registry/Registry.sol
   17:1   warning  Contract has 19 states declarations but allowed no more than 15  max-states-count
   42:22  warning  Variable name must be in mixedCase                               var-name-mixedcase
   88:17  warning  Variable name must be in mixedCase                               var-name-mixedcase
   88:31  warning  Variable name must be in mixedCase                               var-name-mixedcase
   97:9   warning  Error message for require is too long                            reason-string
  116:9   warning  Error message for require is too long                            reason-string
  133:9   warning  Error message for require is too long                            reason-string
  154:9   warning  Error message for require is too long                            reason-string
  170:9   warning  Error message for require is too long                            reason-string
  194:9   warning  Error message for require is too long                            reason-string
  198:9   warning  Error message for require is too long                            reason-string
  199:9   warning  Error message for require is too long                            reason-string
  213:9   warning  Error message for require is too long                            reason-string
  232:9   warning  Error message for require is too long                            reason-string
  235:9   warning  Error message for require is too long                            reason-string
  239:9   warning  Error message for require is too long                            reason-string
  246:9   warning  Error message for require is too long                            reason-string
  274:9   warning  Error message for require is too long                            reason-string
  298:9   warning  Error message for require is too long                            reason-string
  299:9   warning  Error message for require is too long                            reason-string
  306:9   warning  Error message for require is too long                            reason-string
contracts/registry/utils/MelonCouncilOwnable.sol
  11:30  warning  Variable name must be in mixedCase     var-name-mixedcase
  12:30  warning  Variable name must be in mixedCase     var-name-mixedcase
  14:17  warning  Variable name must be in mixedCase     var-name-mixedcase
  14:31  warning  Variable name must be in mixedCase     var-name-mixedcase
  22:9   warning  Error message for revert is too long   reason-string
  32:9   warning  Error message for require is too long  reason-string
contracts/requests/SharesRequestor.sol
   65:67  warning  Code contains empty blocks                                               no-empty-blocks
   70:32  warning  Code contains empty blocks                                               no-empty-blocks
   76:9   warning  Error message for require is too long                                    reason-string
  148:9   warning  Error message for require is too long                                    reason-string
  149:9   warning  Error message for require is too long                                    reason-string
  158:21  warning  Code contains empty blocks                                               no-empty-blocks
  172:9   warning  Error message for require is too long                                    reason-string
  173:9   warning  Error message for require is too long                                    reason-string
  176:9   warning  Error message for require is too long                                    reason-string
  180:9   warning  Error message for require is too long                                    reason-string
  183:9   warning  Error message for require is too long                                    reason-string
  200:28  warning  Avoid to make time-based decisions in your business logic                not-rely-on-time
  203:13  warning  Possible reentrancy vulnerabilities. Avoid state changes after transfer  reentrancy
  234:9   warning  Error message for require is too long                                    reason-string
  241:13  warning  Avoid to make time-based decisions in your business logic                not-rely-on-time
  247:13  warning  Avoid to make time-based decisions in your business logic                not-rely-on-time
✖ 241 problems (0 errors, 241 warnings)
SeanJCasey commented 4 years ago

Let's mute these:

fubhy commented 4 years ago

@SeanJCasey as discussed I updated this PR so that the contracts are not re-formatted with prettier for now but everything is prepared to do so once we are ready for that (current open branches are merged)

I also added a .solhintignore file to skip the /dependencies directory for solhint linting.

fubhy commented 4 years ago

I went ahead and merged this so that I can build the follow-up tooling branch on top of this one already without the hassle.