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

Autofix event name camelcase #533

Merged
merged 5 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
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
5 changes: 5 additions & 0 deletions e2e/08-autofix/contract-name-camelcase/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"contract-name-camelcase": "error"
}
}
61 changes: 61 additions & 0 deletions e2e/08-autofix/contract-name-camelcase/Foo1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

struct not_Used_Struct1 {
uint256 three;
uint256 four;
}

enum __status1_ {
Pending,
Approved,
Rejected
}

struct NotUsedStruct2 {
uint256 three;
uint256 four;
}

enum Status2 {
Pending,
Approved,
Rejected
}

contract __generic {

struct not_UsedStruct3__ {
uint256 three;
uint256 four;
}

enum status3 {
Pending,
Approved,
Rejected
}

struct NotUsedStruct4 {
uint256 three;
uint256 four;
}

enum Status4 {
Pending,
Approved,
Rejected
}

constructor() {}

function function1() pure external {
uint af1 = 0;
af1;
}

function function2() external pure {
uint b;
b;
}
}
61 changes: 61 additions & 0 deletions e2e/08-autofix/contract-name-camelcase/Foo1AfterFix.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

struct NotUsedStruct1 {
uint256 three;
uint256 four;
}

enum Status1 {
Pending,
Approved,
Rejected
}

struct NotUsedStruct2 {
uint256 three;
uint256 four;
}

enum Status2 {
Pending,
Approved,
Rejected
}

contract Generic {

struct NotUsedStruct3 {
uint256 three;
uint256 four;
}

enum Status3 {
Pending,
Approved,
Rejected
}

struct NotUsedStruct4 {
uint256 three;
uint256 four;
}

enum Status4 {
Pending,
Approved,
Rejected
}

constructor() {}

function function1() pure external {
uint af1 = 0;
af1;
}

function function2() external pure {
uint b;
b;
}
}
61 changes: 61 additions & 0 deletions e2e/08-autofix/contract-name-camelcase/Foo1BeforeFix.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

struct not_Used_Struct1 {
uint256 three;
uint256 four;
}

enum __status1_ {
Pending,
Approved,
Rejected
}

struct NotUsedStruct2 {
uint256 three;
uint256 four;
}

enum Status2 {
Pending,
Approved,
Rejected
}

contract __generic {

struct not_UsedStruct3__ {
uint256 three;
uint256 four;
}

enum status3 {
Pending,
Approved,
Rejected
}

struct NotUsedStruct4 {
uint256 three;
uint256 four;
}

enum Status4 {
Pending,
Approved,
Rejected
}

constructor() {}

function function1() pure external {
uint af1 = 0;
af1;
}

function function2() external pure {
uint b;
b;
}
}
5 changes: 5 additions & 0 deletions e2e/08-autofix/event-name-camelcase/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"event-name-camelcase": "error"
}
}
33 changes: 33 additions & 0 deletions e2e/08-autofix/event-name-camelcase/Foo1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

contract Generic {

event not_UsedEvent1(uint256 indexed amount, address account);

event __not_UsedEvent___2(uint256 indexed amount, address indexed account);

event not___UsedEvent3(uint256 amount, address account);

event notUsedEvent4(uint256 indexed amount, address indexed account);

event notUsedEvent5____(uint256 indexed amount, address account);

event __not_UsedEvent6__(uint256 indexed amount, address account);

event OkEvent1(uint256 indexed amount, address account);

event OkEventOk2(uint256 indexed amount, address indexed account);

constructor() {}

function function1() external pure {
uint af1 = 0;
af1;
}

function function2() external pure {
uint b;
b;
}
}
33 changes: 33 additions & 0 deletions e2e/08-autofix/event-name-camelcase/Foo1AfterFix.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

contract Generic {

event NotUsedEvent1(uint256 indexed amount, address account);

event NotUsedEvent2(uint256 indexed amount, address indexed account);

event NotUsedEvent3(uint256 amount, address account);

event NotUsedEvent4(uint256 indexed amount, address indexed account);

event NotUsedEvent5(uint256 indexed amount, address account);

event NotUsedEvent6(uint256 indexed amount, address account);

event OkEvent1(uint256 indexed amount, address account);

event OkEventOk2(uint256 indexed amount, address indexed account);

constructor() {}

function function1() external pure {
uint af1 = 0;
af1;
}

function function2() external pure {
uint b;
b;
}
}
33 changes: 33 additions & 0 deletions e2e/08-autofix/event-name-camelcase/Foo1BeforeFix.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

contract Generic {

event not_UsedEvent1(uint256 indexed amount, address account);

event __not_UsedEvent___2(uint256 indexed amount, address indexed account);

event not___UsedEvent3(uint256 amount, address account);

event notUsedEvent4(uint256 indexed amount, address indexed account);

event notUsedEvent5____(uint256 indexed amount, address account);

event __not_UsedEvent6__(uint256 indexed amount, address account);

event OkEvent1(uint256 indexed amount, address account);

event OkEventOk2(uint256 indexed amount, address indexed account);

constructor() {}

function function1() external pure {
uint af1 = 0;
af1;
}

function function2() external pure {
uint b;
b;
}
}
Loading
Loading