Skip to content

feat:Detect Redundant Constructor Assignments#519

Open
Divineifed1 wants to merge 3 commits into
MDTechLabs:mainfrom
Divineifed1:main
Open

feat:Detect Redundant Constructor Assignments#519
Divineifed1 wants to merge 3 commits into
MDTechLabs:mainfrom
Divineifed1:main

Conversation

@Divineifed1

Copy link
Copy Markdown

close #356

Summary

Adds a new rule to detect redundant constructor initialization — where a constructor re-assigns the same value already declared in a state variable's initializer.

Changes

New Rule: solidity-redundant-constructor-init

  • Directory: libs/rule-engine/src/rules/optimization/deployment/
  • Rule ID: solidity-redundant-constructor-init
  • Severity: Warning

What it detects:

contract Example {
    uint256 public count = 10;  

    constructor() {
        count = 10;  // ❌ redundant — wastes deployment gas
    }
}

@mijinummi

Copy link
Copy Markdown
Collaborator

Hello @Divineifed1 , thanks for your contribution. Please kindly fix the remaining 2 ci contract failures

@mijinummi

Copy link
Copy Markdown
Collaborator

Hello @Divineifed1 , you'll be unassigned in the 12hrs if you didn't fix the errors as requested.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect Redundant Constructor Assignments

3 participants