Skip to content

Commit

Permalink
Merge pull request #536 from protofire/develop
Browse files Browse the repository at this point in the history
Release 4.1.0 - Develop to Master
  • Loading branch information
dbale-altoros authored Jan 8, 2024
2 parents ca7ba78 + d4fae33 commit 301caa7
Show file tree
Hide file tree
Showing 61 changed files with 1,963 additions and 135 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/DOCKER.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Docker Image CI

on:
workflow_dispatch:
inputs:
version:
description: 'Solhint version'
required: true
image_name:
description: 'Name of image to be used on docker hub'
required: true
default: 'protodb/protofire-solhint'
jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Login to Docker Hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: Build Docker image
run: docker build . --file docker/Dockerfile --tag ${{ inputs.image_name }}:${{ inputs.version }} --build-arg VERSION=${{ inputs.version }}

- name: Push Docker image to Docker Hub
run: docker push ${{ inputs.image_name }}:${{ inputs.version }}
3 changes: 3 additions & 0 deletions .github/workflows/E2E.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'npm'

- name: Install dependencies
run: npm install --include=dev
Expand Down Expand Up @@ -55,6 +56,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install dependencies
run: npm install --include=dev
Expand Down Expand Up @@ -92,6 +94,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install dependencies
run: npm install --include=dev
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/TESTS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci
Expand All @@ -41,6 +42,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install dependencies
run: npm ci
Expand All @@ -59,6 +61,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install dependencies
run: npm ci
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ antlr4.jar
/docs/.sass-cache/
_temp/
*solhintReport*.*
.env
**/.DS_Store

23 changes: 22 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
## [4.0] - 2023-10-01
## [4.1.0] - 2024-01- ????????????????????

### Updated
- Included `Sarif` formatter [#530](https://github.com/protofire/solhint/pull/530) (Thanks to [@eshaan7](https://github.com/eshaan7))
- Cache `npm` on workflows [#534](https://github.com/protofire/solhint/pull/534)


### Added
- Official Docker Image [#524](https://github.com/protofire/solhint/pull/524) (Thanks to [@keypee](https://github.com/keypee90))
- Autofix for `payable-fallback` rule [#528](https://github.com/protofire/solhint/pull/528)
- Autofix for `quotes` rule [#529](https://github.com/protofire/solhint/pull/529)
- Autofix for `avoid-suicide` rule [#531](https://github.com/protofire/solhint/pull/531)
- Autofix for `contract-name-camelcase` rule [#532](https://github.com/protofire/solhint/pull/532)
- Autofix for `event-name-camelcase` rule [#533](https://github.com/protofire/solhint/pull/533)

### Fixed
- Fix private vars leading underscore on libraries [#525](https://github.com/protofire/solhint/pull/525)




## [4.0.0] - 2023-10-01

### Updated
- Enhance explicit types sensitivity [#493](https://github.com/protofire/solhint/pull/493) (Thanks to [@vladyan18](https://github.com/vladyan18))
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<p align="center">
<img src="solhint.png">
<a href="https://protofire.io/projects/solhint"><img src="solhint.png"></a>
</p>
<p align="center">
By <a href="https://protofire.io/">Protofire</a>
</p>

[![Join Discord](https://img.shields.io/badge/join-Discord-red)](https://discord.gg/4TYGq3zpjs)
[![](https://img.shields.io/badge/Solhint%20Website-cyan)](https://protofire.io/projects/solhint)
[![](https://img.shields.io/badge/Join%20Our%20Discord-magenta)](https://discord.gg/4TYGq3zpjs)
[![Donate with Ethereum](https://img.shields.io/badge/Donate-ETH-blue)](https://etherscan.io/address/0xA81705c8C247C413a19A244938ae7f4A0393944e)
[![NPM version](https://badge.fury.io/js/solhint.svg)](https://npmjs.org/package/solhint)
[![Coverage Status](https://coveralls.io/repos/github/protofire/solhint/badge.svg?branch=master)](
Expand All @@ -14,8 +15,10 @@ https://coveralls.io/github/protofire/solhint?branch=master)

This is an open source project for linting [Solidity](http://solidity.readthedocs.io/en/develop/) code. This project
provides both **Security** and **Style Guide** validations.

<br>
[VISIT OUR WEBSITE](https://protofire.io/projects/solhint)<br>
[JOIN OUR DISCORD SERVER](https://discord.gg/4TYGq3zpjs)
<br>
## Installation

You can install Solhint using **npm**:
Expand Down Expand Up @@ -57,7 +60,7 @@ Linter for Solidity programming language
Options:
-V, --version output the version number
-f, --formatter [name] report formatter name (stylish, table, tap, unix, json, compact)
-f, --formatter [name] report formatter name (stylish, table, tap, unix, json, compact, sarif)
-w, --max-warnings [maxWarningsNumber] number of allowed warnings
-c, --config [file_name] file to use as your .solhint.json
-q, --quiet report errors only - default: false
Expand Down Expand Up @@ -198,8 +201,11 @@ Or disable all validations for a group of lines:
### Best Practices Rules
[Full list with all supported Best Practices Rules](docs/rules.md#best-practise-rules)

## Documentation
## Docker
### Solhint has an official Docker Image
Go to docker folder and follow [this](docker/docker.md) instructions.

## Documentation
Related documentation you may find [here](https://protofire.github.io/solhint/).

## IDE Integrations
Expand Down
23 changes: 0 additions & 23 deletions ROADMAP.md

This file was deleted.

5 changes: 5 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM node:20-alpine
LABEL maintainer="[email protected]"
ENV VERSION=4.1.0

RUN npm install -g solhint@"$VERSION"
25 changes: 25 additions & 0 deletions docker/docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Docker Instructions
Thanks to [@kaypee90](https://github.com/kaypee90) for the contribution<br><br>

1. Get the image. Run:<br>
`docker pull protodb/protofire-solhint:latest`

2. Check if image is present (protodb/protofire-solhint:latest)<br>
`docker images`

3. Solhint use:<br>

- Execute solhint with default config file<br>
`docker run -v ./:/app -w /app -it protodb/protofire-solhint solhint './contracts/*.sol'`

This command:<br>
- Maps current folder to app/ inside container<br>
- Executes solhint in './contracts/*.sol'<br>

- Navigate inside container sharing current folder into app/ container folder<br>
`docker run -v ./:/app -w /app -it protodb/protofire-solhint /bin/sh`<br>

This command:<br>
- Maps current folder to app/ container folder<br>
- Can run solhint inside the container by typing `solhint ./contracts/*.sol`<br>
(use your correct path, type exit to finish)<br>
2 changes: 1 addition & 1 deletion docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ title: "Rule Index of Solhint"
| Rule Id | Error | Recommended | Deprecated |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- | ------------ | ----------- |
| [const-name-snakecase](./rules/naming/const-name-snakecase.md) | Constant name must be in capitalized SNAKE_CASE. (Does not check IMMUTABLES, use immutable-vars-naming) | $~~~~~~~~$✔️ | |
| [contract-name-camelcase](./rules/naming/contract-name-camelcase.md) | Contract name must be in CamelCase. | $~~~~~~~~$✔️ | |
| [contract-name-camelcase](./rules/naming/contract-name-camelcase.md) | Contract, Structs and Enums should be in CamelCase. | $~~~~~~~~$✔️ | |
| [event-name-camelcase](./rules/naming/event-name-camelcase.md) | Event name must be in CamelCase. | $~~~~~~~~$✔️ | |
| [foundry-test-functions](./rules/naming/foundry-test-functions.md) | Enforce naming convention on functions for Foundry test cases | | |
| [func-name-mixedcase](./rules/naming/func-name-mixedcase.md) | Function name must be in mixedCase. | $~~~~~~~~$✔️ | |
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/best-practises/no-console.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ This rule accepts a string option of rule severity. Must be one of "error", "war
}
```

### Notes
- Solhint allows this rule to automatically fix the code with `--fix` option

## Examples
### 👎 Examples of **incorrect** code for this rule
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/best-practises/payable-fallback.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ This rule accepts a string option of rule severity. Must be one of "error", "war
}
```

### Notes
- Solhint allows this rule to automatically fix the code with `--fix` option

## Examples
### 👍 Examples of **correct** code for this rule
Expand Down
5 changes: 4 additions & 1 deletion docs/rules/naming/contract-name-camelcase.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ title: "contract-name-camelcase | Solhint"

## Description
Contract name must be in CamelCase.
Contract, Structs and Enums should be in CamelCase.

## Options
This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn.
Expand All @@ -26,6 +26,9 @@ This rule accepts a string option of rule severity. Must be one of "error", "war
}
```

### Notes
- Solhint allows this rule to automatically fix the code with `--fix` option
- The FIX will only change first letter and remove underscores

## Examples
This rule does not have examples.
Expand Down
3 changes: 3 additions & 0 deletions docs/rules/naming/event-name-camelcase.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ This rule accepts a string option of rule severity. Must be one of "error", "war
}
```

### Notes
- Solhint allows this rule to automatically fix the code with `--fix` option
- The FIX will only change first letter and remove underscores

## Examples
This rule does not have examples.
Expand Down
3 changes: 2 additions & 1 deletion docs/rules/naming/private-vars-leading-underscore.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ This rule accepts an array of options:
```

### Notes
- This rule considers functions and variables in Libraries as well
- This rule DO NOT considers functions and variables in Libraries
- This rule skips external and public functions
- This rule skips external and public state variables
- See [here](https://docs.soliditylang.org/en/latest/style-guide.html#underscore-prefix-for-non-external-functions-and-variables) for further information
- Solhint allows this rule to automatically fix the code with `--fix` option

## Examples
### 👍 Examples of **correct** code for this rule
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions e2e/08-autofix/avoid-suicide/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"avoid-suicide": "error"
}
}
49 changes: 49 additions & 0 deletions e2e/08-autofix/avoid-suicide/Foo1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/ownership/Suicide.sol';
import { feature as suicide} from '@openzeppelin/contracts/ownership/Suicide.sol';

uint256 constant suicide = 1;

enum MyEnum {
suicide,
B
}

struct OneNiceStruct {
uint256 suicide;
uint256 b;
}

error Unauthorized();

function freeFunction() pure returns (uint256) {
suicide();
return 1;
}

contract Generic {
struct AnotherNiceStruct {
uint256 suicide;
uint256 c;
}

address constant owner = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";

function seekAndestroy1() external {
suicide();
}

function seekAndestroy2() external {
suicide(owner);
}

function seekAndestroy3() external {
selfdestruct();
}

function seekAndestroy4() external {
selfdestruct(owner);
}
}
49 changes: 49 additions & 0 deletions e2e/08-autofix/avoid-suicide/Foo1AfterFix.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/ownership/Suicide.sol';
import { feature as suicide} from '@openzeppelin/contracts/ownership/Suicide.sol';

uint256 constant suicide = 1;

enum MyEnum {
suicide,
B
}

struct OneNiceStruct {
uint256 suicide;
uint256 b;
}

error Unauthorized();

function freeFunction() pure returns (uint256) {
selfdestruct();
return 1;
}

contract Generic {
struct AnotherNiceStruct {
uint256 suicide;
uint256 c;
}

address constant owner = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";

function seekAndestroy1() external {
selfdestruct();
}

function seekAndestroy2() external {
selfdestruct(owner);
}

function seekAndestroy3() external {
selfdestruct();
}

function seekAndestroy4() external {
selfdestruct(owner);
}
}
Loading

0 comments on commit 301caa7

Please sign in to comment.