-
Notifications
You must be signed in to change notification settings - Fork 29
tests: add and follow most of the eslint rules #155
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| { | ||
| "extends" : [ | ||
| "standard", | ||
| "plugin:promise/recommended" | ||
| ], | ||
| "plugins": [ | ||
| "promise" | ||
| ], | ||
| "env": { | ||
| "browser" : true, | ||
| "node" : true, | ||
| "mocha" : true, | ||
| "jest" : true | ||
| }, | ||
| "globals" : { | ||
| "artifacts": false, | ||
| "contract": false, | ||
| "assert": false, | ||
| "web3": false | ||
| }, | ||
| "rules": { | ||
|
|
||
| // Strict mode | ||
| "strict": [2, "global"], | ||
|
|
||
| // Code style | ||
| "indent": [2, 2], | ||
| "quotes": [2, "single"], | ||
| "semi": ["error", "always"], | ||
| "space-before-function-paren": ["error", "always"], | ||
| "no-use-before-define": 0, | ||
| "eqeqeq": [2, "smart"], | ||
| "dot-notation": [2, {"allowKeywords": true, "allowPattern": ""}], | ||
| "no-redeclare": [2, {"builtinGlobals": true}], | ||
| "no-trailing-spaces": [2, { "skipBlankLines": true }], | ||
| "eol-last": 1, | ||
| "comma-spacing": [2, {"before": false, "after": true}], | ||
| "camelcase": [2, {"properties": "always"}], | ||
| "no-mixed-spaces-and-tabs": [2, "smart-tabs"], | ||
| "comma-dangle": [1, "always-multiline"], | ||
| "no-dupe-args": 2, | ||
| "no-dupe-keys": 2, | ||
| "no-debugger": 0, | ||
| "no-undef": 2, | ||
| "object-curly-spacing": [2, "always"], | ||
| "max-len": [2, 120, 2], | ||
| "generator-star-spacing": ["error", "before"], | ||
| "promise/avoid-new": 0, | ||
| "promise/always-return": 0 | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "extends": "solium:all", | ||
| "plugins": ["security"], | ||
| "rules": { | ||
| "quotes": ["error", "double"], | ||
| "no-empty-blocks": "off", | ||
| "indentation": ["error", 2], | ||
| "max-len": ["error", 79], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's use 120 |
||
| "no-constant": ["error"], | ||
| "security/enforce-explicit-visibility": ["error"], | ||
| "security/no-block-members": ["warning"], | ||
| "security/no-inline-assembly": ["warning"], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thinking about our
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, in this repo it's less useful. I like it because it forces us to have a good reason to use assembly, and we can use it as a reminder to put this good reason in a comment on the code. |
||
| "arg-overflow": ["off"] | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import "../upgradeability/AdminUpgradeabilityProxy.sol"; | |
| import "../upgradeability/UpgradeabilityProxyFactory.sol"; | ||
| import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; | ||
|
|
||
|
|
||
| /** | ||
| * @title BaseApp | ||
| * @dev Abstract base contract for upgradeable applications. | ||
|
|
@@ -23,18 +24,14 @@ contract BaseApp is Ownable { | |
| factory = _factory; | ||
| } | ||
|
|
||
| /** | ||
| * @dev Abstract function to return the implementation provider. | ||
| * @return The implementation provider. | ||
| */ | ||
| function getProvider() internal view returns (ImplementationProvider); | ||
|
|
||
| /** | ||
| * @dev Returns the implementation address for a given contract name, provided by the `ImplementationProvider`. | ||
| * @param contractName Name of the contract. | ||
| * @return Address where the contract is implemented. | ||
| */ | ||
| function getImplementation(string contractName) public view returns (address) { | ||
| function getImplementation(string contractName) | ||
| public view returns (address) | ||
| { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| return getProvider().getImplementation(contractName); | ||
| } | ||
|
|
||
|
|
@@ -43,7 +40,10 @@ contract BaseApp is Ownable { | |
| * @param contractName Name of the contract. | ||
| * @return Address of the new proxy. | ||
| */ | ||
| function create(string contractName) public returns (AdminUpgradeabilityProxy) { | ||
| function create(string contractName) | ||
| public | ||
| returns (AdminUpgradeabilityProxy) | ||
| { | ||
| address implementation = getImplementation(contractName); | ||
| return factory.createProxy(this, implementation); | ||
| } | ||
|
|
@@ -58,17 +58,31 @@ contract BaseApp is Ownable { | |
| * https://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector-and-argument-encoding. | ||
| * @return Address of the new proxy. | ||
| */ | ||
| function createAndCall(string contractName, bytes data) payable public returns (AdminUpgradeabilityProxy) { | ||
| function createAndCall( | ||
| string contractName, | ||
| bytes data | ||
| ) | ||
| payable | ||
| public | ||
| returns (AdminUpgradeabilityProxy) | ||
| { | ||
| address implementation = getImplementation(contractName); | ||
| return factory.createProxyAndCall.value(msg.value)(this, implementation, data); | ||
| return factory.createProxyAndCall.value( | ||
| msg.value)(this, implementation, data); | ||
| } | ||
|
|
||
| /** | ||
| * @dev Upgrades a proxy to the newest implementation of a contract. | ||
| * @param proxy Proxy to be upgraded. | ||
| * @param contractName Name of the contract. | ||
| */ | ||
| function upgrade(AdminUpgradeabilityProxy proxy, string contractName) public onlyOwner { | ||
| function upgrade( | ||
| AdminUpgradeabilityProxy proxy, | ||
| string contractName | ||
| ) | ||
| public | ||
| onlyOwner | ||
| { | ||
| address implementation = getImplementation(contractName); | ||
| proxy.upgradeTo(implementation); | ||
| } | ||
|
|
@@ -83,7 +97,15 @@ contract BaseApp is Ownable { | |
| * called, as described in | ||
| * https://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector-and-argument-encoding. | ||
| */ | ||
| function upgradeAndCall(AdminUpgradeabilityProxy proxy, string contractName, bytes data) payable public onlyOwner { | ||
| function upgradeAndCall( | ||
| AdminUpgradeabilityProxy proxy, | ||
| string contractName, | ||
| bytes data | ||
| ) | ||
| payable | ||
| public | ||
| onlyOwner | ||
| { | ||
| address implementation = getImplementation(contractName); | ||
| proxy.upgradeToAndCall.value(msg.value)(implementation, data); | ||
| } | ||
|
|
@@ -93,7 +115,9 @@ contract BaseApp is Ownable { | |
| * This is needed because only the proxy admin can query it. | ||
| * @return The address of the current implementation of the proxy. | ||
| */ | ||
| function getProxyImplementation(AdminUpgradeabilityProxy proxy) public view returns (address) { | ||
| function getProxyImplementation(AdminUpgradeabilityProxy proxy) | ||
| public view returns (address) | ||
| { | ||
| return proxy.implementation(); | ||
| } | ||
|
|
||
|
|
@@ -102,7 +126,16 @@ contract BaseApp is Ownable { | |
| * Only the admin can query it. | ||
| * @return The address of the current admin of the proxy. | ||
| */ | ||
| function getProxyAdmin(AdminUpgradeabilityProxy proxy) public view returns (address) { | ||
| function getProxyAdmin(AdminUpgradeabilityProxy proxy) | ||
| public view returns (address) | ||
| { | ||
| return proxy.admin(); | ||
| } | ||
|
|
||
| /** | ||
| * @dev Abstract function to return the implementation provider. | ||
| * @return The implementation provider. | ||
| */ | ||
| function getProvider() internal view returns (ImplementationProvider); | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this rule shadowing the one defined in
.soliumrc.json?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, this is JS... I'd fix
.soliumrc.jsonto 120