Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 4.1.0 - Develop to Master #536

Merged
merged 54 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
fa38094
added: docker workflow
dbale-altoros Nov 30, 2023
58de651
add: docker image
dbale-altoros Dec 5, 2023
cd58dc9
add: docker image
dbale-altoros Dec 5, 2023
ebe2ec4
Merge pull request #524 from protofire/add-docker-image
dbale-altoros Dec 5, 2023
2509961
fix: private-vars-leading on libraries
dbale-altoros Dec 5, 2023
81e83f7
fix: private-vars-leading on libraries
dbale-altoros Dec 5, 2023
b563193
fix: private-vars-leading on libraries
dbale-altoros Dec 5, 2023
5313f07
fix: private-vars-leading on libraries
dbale-altoros Dec 5, 2023
80bb793
Merge pull request #525 from protofire/fix-private-leading-underscore…
dbale-altoros Dec 5, 2023
7fd3a94
Fix typos
kaypee90 Dec 13, 2023
25e8157
clean up
kaypee90 Dec 13, 2023
a281da1
Merge pull request #526 from kaypee90/fix-typos-in-docker-md-file
dbale-altoros Dec 19, 2023
a29462c
autofix payable-fallback added
dbale-altoros Dec 20, 2023
eb3aed3
fix: e2e folder name
dbale-altoros Dec 20, 2023
dcc74c8
fix: files for e2e
dbale-altoros Dec 20, 2023
ff5e392
test: e2e not workin 1
dbale-altoros Dec 20, 2023
1230b50
test: e2e not workin 2
dbale-altoros Dec 20, 2023
725b1d8
test: e2e not workin 3
dbale-altoros Dec 20, 2023
ade4e98
test: e2e not workin 4
dbale-altoros Dec 20, 2023
46eb0dd
test: e2e not workin 5
dbale-altoros Dec 20, 2023
c072707
test: e2e not workin 6
dbale-altoros Dec 20, 2023
b6c6d73
test: e2e not workin 7
dbale-altoros Dec 20, 2023
1582fe4
Merge branch 'develop' into autofix-payable
dbale-altoros Dec 20, 2023
aeb0255
Merge pull request #528 from protofire/autofix-payable
dbale-altoros Dec 20, 2023
43d4df6
added: autofix quotes
dbale-altoros Dec 20, 2023
0c985ad
feat: add sarif formatter
eshaan7 Dec 21, 2023
f7056e5
autofix avoid suicide
dbale-altoros Dec 21, 2023
ebfb93f
fix linting errors
eshaan7 Dec 21, 2023
03d8cef
fix linting errors
eshaan7 Dec 21, 2023
fdafd50
changed commands folder name e2e
dbale-altoros Dec 21, 2023
1a9fe48
Merge pull request #530 from eshaan7/feat/add-sarif-formatter
dbale-altoros Dec 21, 2023
0f09968
Merge branch 'develop' into autofix-avoid-suicide
dbale-altoros Dec 21, 2023
0e0775f
Merge branch 'develop' into autofix-quotes
dbale-altoros Dec 21, 2023
c6000a0
Merge pull request #529 from protofire/autofix-quotes
dbale-altoros Dec 22, 2023
0e2d611
fixed conflicts merge to develop
dbale-altoros Dec 22, 2023
614b2dc
add: md modifications
dbale-altoros Dec 22, 2023
9a09bb1
Merge branch 'autofix-avoid-suicide' of github.com:protofire/solhint …
dbale-altoros Dec 22, 2023
625cb7f
Merge pull request #531 from protofire/autofix-avoid-suicide
dbale-altoros Dec 22, 2023
e505b3e
autofix: contract-name-camelcase
dbale-altoros Dec 25, 2023
d025f06
autofix: contract-name-camelcase
dbale-altoros Dec 25, 2023
1a3ad58
autofix: contract-name-camelcase
dbale-altoros Dec 25, 2023
e4cce34
autofix: event name camelcase
dbale-altoros Dec 26, 2023
8fe415d
fix: .solhint
dbale-altoros Dec 26, 2023
de76c8a
add: cache npm on workflows
dbale-altoros Dec 29, 2023
5b92a31
Merge pull request #532 from protofire/autofix-contract-camelcase
dbale-altoros Jan 1, 2024
c902e63
Merge pull request #533 from protofire/autofix-event-name-camelcase
dbale-altoros Jan 1, 2024
db68844
Merge branch 'develop' into cache-npm-workflows
dbale-altoros Jan 1, 2024
c2c27d0
Merge pull request #534 from protofire/cache-npm-workflows
dbale-altoros Jan 1, 2024
be1ff57
logfile 4.1.0
dbale-altoros Jan 2, 2024
e0bee3d
Merge pull request #535 from protofire/pre-release-4-1
dbale-altoros Jan 8, 2024
b1e27c7
fix: docker version and readme
dbale-altoros Jan 8, 2024
6a55877
Merge pull request #537 from protofire/pre-release-4-1-b
dbale-altoros Jan 8, 2024
e6b7034
fix: docker yml update
dbale-altoros Jan 8, 2024
d4fae33
Merge pull request #538 from protofire/pre-release-4-1-c
dbale-altoros Jan 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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
Loading