Skip to content

Add documentation and examples for unused variable fixes#9

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/remove-unused-variables
Draft

Add documentation and examples for unused variable fixes#9
Copilot wants to merge 4 commits intomainfrom
copilot/remove-unused-variables

Conversation

Copy link

Copilot AI commented Feb 18, 2026

Demonstrates the unused variable pattern and its fixes per Codacy/SonarLint guidelines.

Changes

  • Documentation: .github/instructions/codacy.instructions.md explaining the issue, compliant/noncompliant patterns, and configuration parameters
  • Examples: examples/noncompliant.py and examples/compliant.py demonstrating the problem and solution
  • README: Overview and repository structure

Pattern

Noncompliant:

def hello(name):
    message = "Hello " + name  # unused
    print(name)

for i in range(10):  # unused loop variable
    foo()

Compliant:

def hello(name):
    message = "Hello " + name
    print(message)  # use the variable

for _ in range(10):  # underscore for intentionally unused
    foo()

Default ignore regex: (_[a-zA-Z0-9_]*|dummy|unused|ignored)

Original prompt

The fix for this issue is straightforward. Once you ensure the unused variable is not part of an incomplete implementation leading to bugs, you just need to remove it.

Noncompliant code example

def hello(name):
message = "Hello " + name # Noncompliant - message is unused
print(name)
for i in range(10): # Noncompliant - i is unused
foo()
Compliant solution

def hello(name):
message = "Hello " + name
print(message)
for _ in range(10):
foo()
Parameters
Following parameter values can be set in the SonarLint:Rules user settings. In connected mode, server side configuration overrides local settings.
regex
Regular expression used to identify variable name to ignore.

(Default value: ([a-zA-Z0-9]*|dummy|unused|ignored))

The user has attached the following file paths as relevant context:

  • .github\instructions\codacy.instructions.md

Created from VS Code.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 18, 2026 12:37
Co-authored-by: ahmedessamX <245457521+ahmedessamX@users.noreply.github.com>
Co-authored-by: ahmedessamX <245457521+ahmedessamX@users.noreply.github.com>
Co-authored-by: ahmedessamX <245457521+ahmedessamX@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove unused variables from code examples Add documentation and examples for unused variable fixes Feb 18, 2026
Copilot AI requested a review from ahmedessamX February 18, 2026 12:41
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.

2 participants