Skip to content

Provide APIs for testing the Scan tool Java APIs#56

Merged
gayaldassanayake merged 1 commit intoballerina-platform:mainfrom
gayaldassanayake:test-apis
Jun 2, 2025
Merged

Provide APIs for testing the Scan tool Java APIs#56
gayaldassanayake merged 1 commit intoballerina-platform:mainfrom
gayaldassanayake:test-apis

Conversation

@gayaldassanayake
Copy link
Copy Markdown
Contributor

Purpose

$ subject

Fixes #27

Approach

Describe how you are implementing the solution.

Check List

Comment thread .github/workflows/central-publish.yml Outdated
Comment thread scan-command-test-utils/build.gradle Outdated
Comment thread scan-command-test-utils/build.gradle Outdated
Comment thread scan-command-test-utils/src/main/java/io/ballerina/scan/test/ScanTestRunner.java Outdated
Comment thread scan-command-test-utils/src/main/java/io/ballerina/scan/test/ScanAssertions.java Outdated
Comment thread scan-command-test-utils/src/main/java/io/ballerina/scan/test/ScanAssertions.java Outdated
@sonarqubecloud
Copy link
Copy Markdown

Comment thread scan-command-test-utils/build.gradle Outdated
Comment thread scan-command-test-utils/build.gradle Outdated
}
}

// Setting up checkstyles
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove these comments, they don't add value?

Comment thread scan-command-test-utils/src/main/java/io/ballerina/scan/test/ScanAssertions.java Outdated
Comment thread scan-command-test-utils/src/main/java/io/ballerina/scan/test/ScanTestRunner.java Outdated
@keizer619 keizer619 requested a review from Copilot May 29, 2025 05:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR exposes internal APIs and utilities in the scan tool to enable Java-based testing, refactors key classes for better test injection, and adds a dedicated test-utils module.

  • Export internal and utils packages to the test module
  • Refactor ScanCmd, ProjectAnalyzer, and related classes to allow custom project loading and rule inspection
  • Add scan-command-test-utils module with test helpers and assertions

Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scan-command/src/main/java/module-info.java Export internal and utils packages to io.ballerina.scan.test
scan-command/src/main/java/io/ballerina/scan/internal/ScanCmd.java Replace argList with projectPath, add constructor overloads, expose getProjectAnalyzer and getAllRules
scan-command/src/main/java/io/ballerina/scan/internal/ProjectAnalyzer.java Make class public, add protected getScannerContext extension point
scan-command/src/main/java/io/ballerina/scan/internal/ReporterImpl.java Change class and method visibilities to support subclassing in tests
scan-command-test-utils/src/main/java/module-info.java Define new test module io.ballerina.scan.test
scan-command-test-utils/src/... Add test utilities (TestScanCmd, TestProjectAnalyzer, ScanTestRunner, assertions, etc.)
build configuration and workflows Bump Ballerina version, add test dependencies for ballerina-lang
Comments suppressed due to low confidence (1)

scan-command-test-utils/src/main/java/module-info.java:1

  • Add a requires io.ballerina.projects; statement so classes referencing io.ballerina.projects.Project can compile under this module.
module io.ballerina.scan.test {

Comment thread scan-command/src/main/java/io/ballerina/scan/internal/ScanCmd.java
Comment thread scan-command/src/main/java/io/ballerina/scan/internal/ScanCmd.java
MaryamZi
MaryamZi previously approved these changes May 30, 2025
Comment thread scan-command-test-utils/src/main/java/io/ballerina/scan/test/Assertions.java Outdated
Comment thread scan-command-test-utils/src/main/java/io/ballerina/scan/test/TestReporter.java Outdated
MaryamZi
MaryamZi previously approved these changes Jun 2, 2025
Comment thread gradle.properties Outdated
Provide test APIs

Improve the APIs

Restructure the APIs

Add assertHasRule

Fix spotbugs errors

Fix failing tests

Refactor the code
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Jun 2, 2025

@codecov
Copy link
Copy Markdown

codecov bot commented Jun 2, 2025

Codecov Report

Attention: Patch coverage is 62.06897% with 11 lines in your changes missing coverage. Please review.

Project coverage is 86.42%. Comparing base (550a043) to head (82c041f).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
.../main/java/io/ballerina/scan/internal/ScanCmd.java 54.16% 11 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main      #56      +/-   ##
============================================
- Coverage     87.57%   86.42%   -1.16%     
  Complexity      308      308              
============================================
  Files            19       19              
  Lines           982      987       +5     
  Branches        153      151       -2     
============================================
- Hits            860      853       -7     
- Misses           64       76      +12     
  Partials         58       58              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gayaldassanayake gayaldassanayake merged commit cf83349 into ballerina-platform:main Jun 2, 2025
3 of 5 checks passed
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.

Add a Public API to Engage the Scan Tool and Verify the Output

4 participants