Skip to content

Commit

Permalink
introduce solhint
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele committed Feb 7, 2024
1 parent a8890a0 commit ed1e0c3
Show file tree
Hide file tree
Showing 11 changed files with 2,225 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ jobs:
- name: Run tests
run: make SOLC_VERSION=${{ env.SOLC_VERSION }} test

- name: Check code formatting
run: make check-fmt
- name: Lint
run: make lint
15 changes: 15 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"rules": {
"no-unused-vars": "error",
"no-unused-import": "error",
"imports-on-top": "error",
"no-global-import": "error",
"const-name-snakecase": "error",
"contract-name-camelcase": "error",
"event-name-camelcase": "error",
"func-name-mixedcase": "error",
"func-param-name-mixedcase": "error",
"modifier-name-mixedcase": "error",
"var-name-mixedcase": "error"
}
}
3 changes: 3 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
contracts/proto
contracts/Asn1Decode.sol
test/
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ fmt:
.PHONY: check-fmt
check-fmt:
@$(MAKE) FORGE_FMT_OPTS=--check fmt

.PHONY: lint
lint:
@npx solhint 'contracts/*.sol'
@$(MAKE) FORGE_FMT_OPTS=--check fmt
13 changes: 7 additions & 6 deletions contracts/AVRValidator.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.12;

import "@ensdomains/ens-contracts/contracts/dnssec-oracle/algorithms/RSAVerify.sol";
import "@ensdomains/ens-contracts/contracts/dnssec-oracle/BytesUtils.sol";
import "solidity-datetime/contracts/DateTime.sol";
import "base64/base64.sol";
import "./Asn1Decode.sol";
import "./LCPUtils.sol";
import {RSAVerify} from "@ensdomains/ens-contracts/contracts/dnssec-oracle/algorithms/RSAVerify.sol";
import {BytesUtils} from "@ensdomains/ens-contracts/contracts/dnssec-oracle/BytesUtils.sol";
import {Base64} from "base64/base64.sol";
import {Asn1Decode, NodePtr} from "./Asn1Decode.sol";
import {LCPUtils} from "./LCPUtils.sol";

/**
* @dev AVRValidator provides the validation functions of Intel's Attestation Verification Report(AVR)
Expand Down Expand Up @@ -438,8 +437,10 @@ library AVRValidator {
uint256 val = 0;
uint8 zero = uint8(48); //0
uint8 nine = uint8(57); //9
// solhint-disable-next-line var-name-mixedcase
uint8 A = uint8(65); //A
uint8 a = uint8(97); // a
// solhint-disable-next-line var-name-mixedcase
uint8 F = uint8(70); //F
uint8 f = uint8(102); //f
for (uint256 i = 0; i < 4; ++i) {
Expand Down
17 changes: 8 additions & 9 deletions contracts/LCPClient.sol
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.12;

import "@hyperledger-labs/yui-ibc-solidity/contracts/core/02-client/ILightClient.sol";
import "@hyperledger-labs/yui-ibc-solidity/contracts/core/02-client/IBCHeight.sol";
import "@hyperledger-labs/yui-ibc-solidity/contracts/proto/Client.sol";
import {GoogleProtobufAny as Any} from "@hyperledger-labs/yui-ibc-solidity/contracts/proto/GoogleProtobufAny.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {ILightClient} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/02-client/ILightClient.sol";
import {IBCHeight} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/02-client/IBCHeight.sol";
import {Height} from "@hyperledger-labs/yui-ibc-solidity/contracts/proto/Client.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {
IbcLightclientsLcpV1ClientState as ProtoClientState,
IbcLightclientsLcpV1ConsensusState as ProtoConsensusState,
IbcLightclientsLcpV1RegisterEnclaveKeyMessage as RegisterEnclaveKeyMessage,
IbcLightclientsLcpV1UpdateClientMessage as UpdateClientMessage
} from "./proto/ibc/lightclients/lcp/v1/LCP.sol";
import "./LCPCommitment.sol";
import "./LCPProtoMarshaler.sol";
import "./LCPUtils.sol";
import "./AVRValidator.sol";
import {LCPCommitment} from "./LCPCommitment.sol";
import {LCPProtoMarshaler} from "./LCPProtoMarshaler.sol";
import {LCPUtils} from "./LCPUtils.sol";
import {AVRValidator} from "./AVRValidator.sol";

contract LCPClient is ILightClient {
using IBCHeight for Height.Data;
Expand Down
2 changes: 1 addition & 1 deletion contracts/LCPCommitment.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.12;

import "@hyperledger-labs/yui-ibc-solidity/contracts/proto/Client.sol";
import {Height} from "@hyperledger-labs/yui-ibc-solidity/contracts/proto/Client.sol";

library LCPCommitment {
uint16 constant LCP_MESSAGE_VERSION = 1;
Expand Down
4 changes: 2 additions & 2 deletions contracts/LCPUtils.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.12;

import "@ensdomains/ens-contracts/contracts/dnssec-oracle/BytesUtils.sol";
import "solidity-datetime/contracts/DateTime.sol";
import {BytesUtils} from "@ensdomains/ens-contracts/contracts/dnssec-oracle/BytesUtils.sol";
import {DateTime} from "solidity-datetime/contracts/DateTime.sol";

library LCPUtils {
/**
Expand Down
Loading

0 comments on commit ed1e0c3

Please sign in to comment.