Skip to content

Fix PMD UseCollectionIsEmpty and UnnecessaryFullyQualifiedName violations#4449

Merged
shai-almog merged 2 commits intomasterfrom
codex/fix-pmd-violations-for-collection-checks
Jan 20, 2026
Merged

Fix PMD UseCollectionIsEmpty and UnnecessaryFullyQualifiedName violations#4449
shai-almog merged 2 commits intomasterfrom
codex/fix-pmd-violations-for-collection-checks

Conversation

@shai-almog
Copy link
Collaborator

Motivation

  • Eliminate many PMD warnings by replacing size() comparisons with isEmpty()/!isEmpty() and remove unnecessary fully-qualified names to improve code clarity and static-analysis results.
  • Make the PMD rules UseCollectionIsEmpty and UnnecessaryFullyQualifiedName cause CI quality-report failures so regressions are caught early.

Description

  • Replaced collection size comparisons such as size() == 0, size() > 0, size() != 0, and size() < 1 with isEmpty() or !isEmpty() across many source files (examples: XYSeriesRenderer, MathHelper, XYChart, NetworkManager, JSONParser, Result, HTMLComponent, etc.).
  • Fixed an incorrect expression in Result.java (((List) !selected) -> !((List) selected).isEmpty()).
  • Removed unnecessary fully-qualified references and relied on existing imports or static imports (examples: MathUtil.atan2 in PieMapper, Container and BorderLayout uses, Date, String, IOException and other common java types).
  • Normalized imports/typedefs in a number of files (e.g. File.java, URL.java, AsyncResource.java, CSSBorder.java) to avoid redundant qualification and to use the already-imported types or static imports.
  • Updated the quality-report script .github/scripts/generate-quality-report.py to add UnnecessaryFullyQualifiedName and UseCollectionIsEmpty to the set of forbidden PMD rules so such violations fail the report generation.

Testing

  • No automated tests (unit or integration) were executed as part of this change.

Codex Task

@github-actions
Copy link

✅ Continuous Quality Report

Test & Coverage

Static Analysis

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Collaborator Author

shai-almog commented Jan 20, 2026

Compared 30 screenshots: 30 matched.

Native Android coverage

  • 📊 Line coverage: 24.71% (2648/10717 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 24.21% (12234/50528), branch 15.18% (709/4672), complexity 17.43% (739/4241), method 32.75% (596/1820), class 33.99% (103/303)
    • Lowest covered classes
      • com.codename1.impl.android.com.codename1.impl.android.AndroidContactsManager – 0.00% (0/400 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.AndroidImplementation$Video – 0.00% (0/168 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.IntentIntegrator – 0.00% (0/139 lines covered)
      • com.codename1.impl.android.util.com.codename1.impl.android.util.Base64 – 0.00% (0/117 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.AndroidImplementation$SocketImpl – 0.00% (0/77 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.AndroidTextureView – 0.00% (0/76 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.AndroidSurfaceView – 0.00% (0/73 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.LocalNotificationPublisher – 0.00% (0/65 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.FridaDetectionUtil – 0.00% (0/64 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.PushNotificationService – 0.00% (0/59 lines covered)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 24.71% (2648/10717 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 24.21% (12234/50528), branch 15.18% (709/4672), complexity 17.43% (739/4241), method 32.75% (596/1820), class 33.99% (103/303)
    • Lowest covered classes
      • com.codename1.impl.android.com.codename1.impl.android.AndroidContactsManager – 0.00% (0/400 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.AndroidImplementation$Video – 0.00% (0/168 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.IntentIntegrator – 0.00% (0/139 lines covered)
      • com.codename1.impl.android.util.com.codename1.impl.android.util.Base64 – 0.00% (0/117 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.AndroidImplementation$SocketImpl – 0.00% (0/77 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.AndroidTextureView – 0.00% (0/76 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.AndroidSurfaceView – 0.00% (0/73 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.LocalNotificationPublisher – 0.00% (0/65 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.FridaDetectionUtil – 0.00% (0/64 lines covered)
      • com.codename1.impl.android.com.codename1.impl.android.PushNotificationService – 0.00% (0/59 lines covered)

@shai-almog
Copy link
Collaborator Author

shai-almog commented Jan 20, 2026

iOS screenshot updates

Compared 30 screenshots: 23 matched, 6 updated, 1 missing reference.

  • BrowserComponent — updated screenshot. Screenshot differs (1206x2622 px, bit depth 8).

    BrowserComponent
    Preview info: Preview provided by instrumentation.
    Full-resolution PNG saved as BrowserComponent.png in workflow artifacts.

  • graphics-draw-arc — updated screenshot. Screenshot differs (1206x2622 px, bit depth 8).

    graphics-draw-arc
    Preview info: JPEG preview quality 20; JPEG preview quality 20; downscaled to 603x1311.
    Full-resolution PNG saved as graphics-draw-arc.png in workflow artifacts.

  • graphics-draw-gradient — updated screenshot. Screenshot differs (1206x2622 px, bit depth 8).

    graphics-draw-gradient
    Preview info: JPEG preview quality 10; JPEG preview quality 10; downscaled to 844x1835.
    Full-resolution PNG saved as graphics-draw-gradient.png in workflow artifacts.

  • graphics-draw-round-rect — missing reference. Reference screenshot missing at /Users/runner/work/CodenameOne/CodenameOne/scripts/ios/screenshots/graphics-draw-round-rect.png.

    graphics-draw-round-rect
    Preview info: JPEG preview quality 10; JPEG preview quality 10; downscaled to 844x1835.
    Full-resolution PNG saved as graphics-draw-round-rect.png in workflow artifacts.

  • graphics-draw-string — updated screenshot. Screenshot differs (1206x2622 px, bit depth 8).

    graphics-draw-string
    Preview info: JPEG preview quality 10; JPEG preview quality 10; downscaled to 422x918.
    Full-resolution PNG saved as graphics-draw-string.png in workflow artifacts.

  • graphics-draw-string-decorated — updated screenshot. Screenshot differs (1206x2622 px, bit depth 8).

    graphics-draw-string-decorated
    Preview info: JPEG preview quality 10; JPEG preview quality 10; downscaled to 603x1311.
    Full-resolution PNG saved as graphics-draw-string-decorated.png in workflow artifacts.

  • kotlin — updated screenshot. Screenshot differs (1206x2622 px, bit depth 8).

    kotlin
    Preview info: Preview provided by instrumentation.
    Full-resolution PNG saved as kotlin.png in workflow artifacts.

Benchmark Results

  • VM Translation Time: 346 seconds
  • Compilation Time: 153 seconds

Detailed Performance Metrics

Metric Duration
Build Time Statistics
Setup & Unzip 35515 ms
Extract Extensions 16 ms
Google Services Setup 2 ms
Scan Classes 780 ms
Extract Libs 1766 ms
Inject Build Hints 56 ms
Generate Unit Tests 4 ms
Generate Stubs 1439 ms
Compile Stubs 2755 ms
Generate Icons 1441 ms
Prepare ParparVM 279 ms
ParparVM Execution 186509 ms
Post-VM Setup 145 ms
CocoaPods 4351 ms
Finalize 31 ms
Total Time 235089 msMaven Overhead : 111000 ms
CocoaPods Install (Script) 2000 ms
Simulator Boot (Run) 94000 ms
App Install 20000 ms
App Launch 24000 ms
Test Execution 185000 ms

@shai-almog shai-almog merged commit e77dec5 into master Jan 20, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant