Skip to content
This repository has been archived by the owner on Dec 13, 2019. It is now read-only.

Commit

Permalink
[contracts lint] Add solium max-len -> 80 and fixed linting (#346)
Browse files Browse the repository at this point in the history
* Add solium max-len -> 80 and fixed linting

Co-Authored-By: Alonski <alonzorz@gmail.com>
  • Loading branch information
Alonski committed Dec 16, 2018
1 parent a13d8a5 commit 107e2d7
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 29 deletions.
25 changes: 13 additions & 12 deletions packages/contracts/.soliumrc.json
Expand Up @@ -2,26 +2,27 @@
"extends": "solium:all",
"plugins": ["security"],
"rules": {
"imports-on-top": 1,
"variable-declarations": 1,
"arg-overflow": ["error", 8],
"array-declarations": 1,
"operator-whitespace": 1,
"camelcase": 1,
"deprecated-suicide": 1,
"imports-on-top": 1,
"indentation": ["error", 2],
"lbrace": 1,
"max-len": ["error", 80],
"mixedcase": 0,
"camelcase": 1,
"uppercase": 1,
"no-empty-blocks": 1,
"no-experimental": 0,
"no-unused-vars": 1,
"quotes": 1,
"indentation": ["error", 2],
"arg-overflow": ["error", 8],
"whitespace": 1,
"deprecated-suicide": 1,
"operator-whitespace": 1,
"pragma-on-top": 1,
"no-experimental": 0,
"quotes": 1,
"security/enforce-explicit-visibility": ["error"],
"security/no-block-members": ["warning"],
"security/no-inline-assembly": 0,
"security/no-low-level-calls": 0,
"security/no-inline-assembly": 0
"uppercase": 1,
"variable-declarations": 1,
"whitespace": 1
}
}
4 changes: 3 additions & 1 deletion packages/contracts/contracts/MinimumViableMultisig.sol
Expand Up @@ -82,7 +82,9 @@ contract MinimumViableMultisig {
view
returns (bytes32)
{
return keccak256(abi.encodePacked(byte(0x19), _owners, to, value, data, uint8(operation)));
return keccak256(
abi.encodePacked(byte(0x19), _owners, to, value, data, uint8(operation))
);
}
/// @notice A getter function for the owners of the multisig
Expand Down
9 changes: 7 additions & 2 deletions packages/contracts/contracts/NonceRegistry.sol
Expand Up @@ -30,7 +30,10 @@ contract NonceRegistry {
view
returns (bool)
{
return (table[key].finalizesAt <= block.number) && (table[key].nonceValue == expectedNonceValue);
return (
(table[key].finalizesAt <= block.number) &&
(table[key].nonceValue == expectedNonceValue)
);
}

function isNonceSet(bytes32 key) external view returns (bool) {
Expand All @@ -41,7 +44,9 @@ contract NonceRegistry {
/// Trigger the timeout period to begin if the nonce is set for the first time.
/// @param salt A salt used to generate the nonce key
/// @param nonceValue A nonce at which to set the computed key's value in the mapping
function setNonce(uint256 timeout, bytes32 salt, uint256 nonceValue) external {
function setNonce(uint256 timeout, bytes32 salt, uint256 nonceValue)
external
{
bytes32 key = computeKey(msg.sender, timeout, salt);
require(
table[key].nonceValue < nonceValue,
Expand Down
8 changes: 6 additions & 2 deletions packages/contracts/contracts/appDefinitions/Nim.sol
Expand Up @@ -43,7 +43,9 @@ contract Nim {
returns (bytes)
{
require(action.pileIdx < 3, "pileIdx must be 0, 1 or 2");
require(state.pileHeights[action.pileIdx] >= action.takeAmnt, "invalid pileIdx");
require(
state.pileHeights[action.pileIdx] >= action.takeAmnt, "invalid pileIdx"
);

AppState memory ret = state;

Expand Down Expand Up @@ -85,7 +87,9 @@ contract Nim {
pure
returns (bool)
{
return ((state.pileHeights[0] == 0) && (state.pileHeights[1] == 0) && (state.pileHeights[2] == 0));
return (
(state.pileHeights[0] == 0) && (state.pileHeights[1] == 0) && (state.pileHeights[2] == 0)
);
}


Expand Down
42 changes: 32 additions & 10 deletions packages/contracts/contracts/appDefinitions/TicTacToe.sol
Expand Up @@ -146,31 +146,53 @@ contract TicTacToe {
returns (AppState)
{
require(state.board[x][y] == 0, "playMove: square is not empty");
require(playerId == 0 || playerId == 1, "playMove: playerId not in range [0, 1]");
require(
playerId == 0 || playerId == 1, "playMove: playerId not in range [0, 1]"
);

state.board[x][y] = playerId + 1;

return state;
}

function assertBoardIsFull(AppState preState) internal pure {
function assertBoardIsFull(AppState preState)
internal
pure
{
for (uint256 i = 0; i < 3; i++) {
for (uint256 j = 0; j < 3; j++) {
require(preState.board[i][j] != 0, "assertBoardIsFull: square is empty");
require(
preState.board[i][j] != 0, "assertBoardIsFull: square is empty"
);
}
}
}

function assertWin(uint256 playerId, AppState state, WinClaim winClaim) internal pure {
function assertWin(uint256 playerId, AppState state, WinClaim winClaim)
internal
pure
{
uint256 expectedSquareState = playerId + 1;
if (winClaim.winClaimType == WinClaimType.COL) {
require(state.board[winClaim.idx][0] == expectedSquareState, "Win Claim not valid");
require(state.board[winClaim.idx][1] == expectedSquareState, "Win Claim not valid");
require(state.board[winClaim.idx][2] == expectedSquareState, "Win Claim not valid");
require(
state.board[winClaim.idx][0] == expectedSquareState, "Win Claim not valid"
);
require(
state.board[winClaim.idx][1] == expectedSquareState, "Win Claim not valid"
);
require(
state.board[winClaim.idx][2] == expectedSquareState, "Win Claim not valid"
);
} else if (winClaim.winClaimType == WinClaimType.ROW) {
require(state.board[0][winClaim.idx] == expectedSquareState, "Win Claim not valid");
require(state.board[1][winClaim.idx] == expectedSquareState, "Win Claim not valid");
require(state.board[2][winClaim.idx] == expectedSquareState, "Win Claim not valid");
require(
state.board[0][winClaim.idx] == expectedSquareState, "Win Claim not valid"
);
require(
state.board[1][winClaim.idx] == expectedSquareState, "Win Claim not valid"
);
require(
state.board[2][winClaim.idx] == expectedSquareState, "Win Claim not valid"
);
} else if (winClaim.winClaimType == WinClaimType.DIAG) {
require(state.board[0][0] == expectedSquareState, "Win Claim not valid");
require(state.board[1][1] == expectedSquareState, "Win Claim not valid");
Expand Down
4 changes: 3 additions & 1 deletion packages/contracts/contracts/lib/Signatures.sol
Expand Up @@ -45,7 +45,9 @@ library Signatures {
{
address lastSigner = address(0);
for (uint256 i = 0; i < signers.length; i++) {
require((signers[i] == recoverKey(signatures, txHash, i)), "Invalid signature");
require(
signers[i] == recoverKey(signatures, txHash, i), "Invalid signature"
);
require(signers[i] > lastSigner, "Signers not in ascending order");
lastSigner = signers[i];
}
Expand Down
4 changes: 3 additions & 1 deletion packages/contracts/contracts/lib/StaticCall.sol
Expand Up @@ -100,7 +100,9 @@ library StaticCall {
private
view
{
require(to.isContract(), "Attempted to make a static call on non-conract address");
require(
to.isContract(), "Attempted to make a static call on non-contract address"
);
assembly {
let result := staticcall(gas, to, add(data, 0x20), mload(data), 0, 0)
let size := returndatasize
Expand Down

0 comments on commit 107e2d7

Please sign in to comment.