Skip to content

Conversation

Copy link

Copilot AI commented Oct 29, 2025

Static analysis identified multiple anti-patterns affecting code maintainability and readability across test and source files.

Changes

Magic numbers → Named constants

  • Test files: Replaced 12 hardcoded numeric literals with descriptive constants
    • BoardTest: 3MAX_WIDTH/MAX_HEIGHT
    • PlayerTest: 10, 20, 30TEST_POINTS_FIRST/TEST_POINTS_SECOND/EXPECTED_TOTAL_SCORE
    • GhostColorTest, DirectionTest, PelletTest, GhostCollisionTest: Similar replacements

Code duplication → Shared constant

  • Ghost subclasses (Blinky, Pinky, Inky, Clyde) all defined identical INTERVAL_VARIATION = 50
  • Extracted to base Ghost class as DEFAULT_INTERVAL_VARIATION
// Before: Duplicated in each ghost class
private static final int INTERVAL_VARIATION = 50;
super(spriteMap, MOVE_INTERVAL, INTERVAL_VARIATION);

// After: Shared in base class
protected static final int DEFAULT_INTERVAL_VARIATION = 50;
super(spriteMap, MOVE_INTERVAL, DEFAULT_INTERVAL_VARIATION);

Method length violation

  • GhostCollisionTest.setUp(): 32 lines → Extracted createTestBoard(), createGhostList(), createStartSquaresList()

Code quality

  • Removed commented dead code in Level.java
  • Fixed indentation and trailing whitespace

Result

Checkstyle violations: 12 → 0

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.puppycrawl.com
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.23.1/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.23.1/x64/codeql/xml/tools/xml-extractor.jar --fileList=/home/REDACTED/work/jpacman-framework-test/.codeql-scratch/dbs/java/working/files-to-index6976283046090517522.list --sourceArchiveDir=/home/REDACTED/work/jpacman-framework-test/.codeql-scratch/dbs/java/src --outputDir=/home/REDACTED/work/jpacman-framework-test/.codeql-scratch/dbs/java/trap/java (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Find anti patterns in this project.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits October 29, 2025 18:58
Co-authored-by: jkrinke <3253748+jkrinke@users.noreply.github.com>
Co-authored-by: jkrinke <3253748+jkrinke@users.noreply.github.com>
Co-authored-by: jkrinke <3253748+jkrinke@users.noreply.github.com>
Copilot AI changed the title [WIP] Identify anti patterns in project Eliminate anti-patterns: magic numbers, code duplication, and code quality issues Oct 29, 2025
Copilot AI requested a review from jkrinke October 29, 2025 19:09
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