-
Notifications
You must be signed in to change notification settings - Fork 43
Add bal scan rule for configurable variables #1175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
bfcf7fc
[Automated] Update the native jar versions
daneshk 81f6934
[Automated] Update the native jar versions
daneshk b52546a
[Automated] Update the native jar versions
daneshk 491dc74
[Automated] Update the native jar versions
daneshk 5a2b83a
Add bal scan rule for configurable variables
daneshk ce3386e
Merge branch 'master' into master
daneshk 9b1282c
Apply suggestions from code review
daneshk 864827d
fix test failiure
daneshk 8862f36
Apply suggestions from code review
daneshk b64cbec
Merge branch 'master' into master
daneshk 81d0c7d
Address review changes
daneshk 99d77ad
Add since annotation
daneshk 3edb530
Fix review suggestions
daneshk 65b948d
Merge branch 'master' into master
daneshk db88d73
Add import alias support
daneshk c4d630c
add compiler plugin path
daneshk 146c036
Merge branch 'master' into master
daneshk e7fa0cb
enable jacoco in compiler plugin tests
daneshk 71c8468
ignore the compiler-plugin until sortout the coverage issue
daneshk 43dc2c5
Merge branch 'master' into master
daneshk fff3b2d
Merge branch 'master' into master
daneshk 60617b5
Merge branch 'master' into master
TharmiganK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,3 +42,5 @@ integration-tests/Dependencies.toml | |
| # Ballerina | ||
| velocity.log* | ||
| *Ballerina.lock | ||
|
|
||
| compiler-plugin-tests/**/target | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| [plugin] | ||
| id = "log-compiler-plugin" | ||
| class = "io.ballerina.stdlib.log.plugin.LogCompilerPlugin" | ||
| class = "io.ballerina.stdlib.log.compiler.LogCompilerPlugin" | ||
|
|
||
| [[dependency]] | ||
| path = "../compiler-plugin/build/libs/log-compiler-plugin-2.11.0.jar" | ||
| path = "../compiler-plugin/build/libs/log-compiler-plugin-2.11.1-SNAPSHOT.jar" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| [plugin] | ||
| id = "log-compiler-plugin" | ||
| class = "io.ballerina.stdlib.log.plugin.LogCompilerPlugin" | ||
| class = "io.ballerina.stdlib.log.compiler.LogCompilerPlugin" | ||
|
|
||
| [[dependency]] | ||
| path = "../compiler-plugin/build/libs/log-compiler-plugin-@project.version@.jar" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| /* | ||
| * Copyright (c) 2025, WSO2 LLC. (http://www.wso2.org). | ||
| * | ||
| * WSO2 LLC. licenses this file to you under the Apache License, | ||
| * Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| plugins { | ||
| id 'java' | ||
| id 'checkstyle' | ||
| id 'com.github.spotbugs' | ||
| } | ||
|
|
||
| description = 'Ballerina - Cache Compiler Plugin Tests' | ||
|
|
||
| dependencies { | ||
| checkstyle project(':checkstyle') | ||
| checkstyle "com.puppycrawl.tools:checkstyle:${checkstylePluginVersion}" | ||
|
|
||
| implementation project(':log-compiler-plugin') | ||
|
|
||
| testImplementation group: 'org.ballerinalang', name: 'ballerina-lang', version: "${ballerinaLangVersion}" | ||
| testImplementation group: 'org.ballerinalang', name: 'ballerina-tools-api', version: "${ballerinaLangVersion}" | ||
| testImplementation group: 'org.ballerinalang', name: 'ballerina-parser', version: "${ballerinaLangVersion}" | ||
|
|
||
| implementation group: 'org.testng', name: 'testng', version: "${testngVersion}" | ||
| } | ||
|
|
||
| tasks.withType(JavaCompile) { | ||
| options.encoding = 'UTF-8' | ||
| } | ||
|
|
||
| sourceCompatibility = JavaVersion.VERSION_21 | ||
|
|
||
| test { | ||
| systemProperty "ballerina.offline.flag", "true" | ||
| useTestNG() { | ||
| suites 'src/test/resources/testng.xml' | ||
| } | ||
| testLogging.showStandardStreams = true | ||
| testLogging { | ||
| events "PASSED", "FAILED", "SKIPPED" | ||
| afterSuite { desc, result -> | ||
| if (!desc.parent) { // will match the outermost suite | ||
| def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)" | ||
| def startItem = '| ', endItem = ' |' | ||
| def repeatLength = startItem.length() + output.length() + endItem.length() | ||
| println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength)) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| spotbugsTest { | ||
| def classLoader = plugins["com.github.spotbugs"].class.classLoader | ||
| def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence") | ||
| def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort") | ||
| ignoreFailures = true | ||
| effort = SpotBugsEffort.MAX | ||
| reportLevel = SpotBugsConfidence.LOW | ||
| reportsDir = file("$project.buildDir/reports/spotbugs") | ||
| def excludeFile = file("${rootDir}/build-config/spotbugs-exclude.xml") | ||
| if (excludeFile.exists()) { | ||
| it.excludeFilter = excludeFile | ||
| } | ||
| reports { | ||
| text.enabled = true | ||
| } | ||
| } | ||
|
|
||
| spotbugsMain { | ||
| enabled false | ||
| } | ||
|
|
||
| task validateSpotbugs() { | ||
| doLast { | ||
| if (spotbugsMain.reports.size() > 0 && | ||
| spotbugsMain.reports[0].destination.exists() && | ||
| spotbugsMain.reports[0].destination.text.readLines().size() > 0) { | ||
| spotbugsMain.reports[0].destination?.eachLine { | ||
| println 'Failure: ' + it | ||
| } | ||
| throw new GradleException("Spotbugs rule violations were found."); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| tasks.withType(Checkstyle) { | ||
| exclude '**/module-info.java' | ||
| } | ||
|
|
||
| checkstyle { | ||
| toolVersion "${project.checkstylePluginVersion}" | ||
| configFile rootProject.file("build-config/checkstyle/build/checkstyle.xml") | ||
| configProperties = ["suppressionFile": file("${rootDir}/build-config/checkstyle/build/suppressions.xml")] | ||
| } | ||
|
|
||
| checkstyleMain { | ||
| enabled false | ||
| } | ||
|
|
||
| spotbugsTest.finalizedBy validateSpotbugs | ||
| checkstyleTest.dependsOn ':checkstyle:downloadCheckstyleRuleFiles' | ||
|
|
||
| compileJava { | ||
| doFirst { | ||
| options.compilerArgs = [ | ||
| '--module-path', classpath.asPath, | ||
| ] | ||
| classpath = files() | ||
| } | ||
| } | ||
|
|
||
| test.dependsOn ":log-ballerina:build" | ||
| build.dependsOn ":log-ballerina:build" | ||
64 changes: 64 additions & 0 deletions
64
...c/test/java/io/ballerina/stdlib/log/compiler/staticcodeanalyzer/ProcessOutputGobbler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * Copyright (c) 2025, WSO2 LLC. (http://www.wso2.org). | ||
| * | ||
| * WSO2 LLC. licenses this file to you under the Apache License, | ||
| * Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package io.ballerina.stdlib.log.compiler.staticcodeanalyzer; | ||
|
|
||
| import java.io.BufferedReader; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.io.InputStreamReader; | ||
| import java.nio.charset.StandardCharsets; | ||
|
|
||
| /** | ||
| * Helper class to consume the process streams. | ||
| */ | ||
| class ProcessOutputGobbler implements Runnable { | ||
| private final InputStream inputStream; | ||
| private final StringBuilder output; | ||
| private int exitCode; | ||
|
|
||
| public ProcessOutputGobbler(InputStream inputStream) { | ||
| this.inputStream = inputStream; | ||
| this.output = new StringBuilder(); | ||
| } | ||
|
|
||
| @Override | ||
| public void run() { | ||
| try (BufferedReader reader = new BufferedReader( | ||
| new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { | ||
| String line; | ||
| while ((line = reader.readLine()) != null) { | ||
| output.append(line).append("\n"); | ||
| } | ||
| } catch (IOException e) { | ||
| this.output.append(e.getMessage()); | ||
| } | ||
| } | ||
|
|
||
| public String getOutput() { | ||
| return output.toString(); | ||
| } | ||
|
|
||
| public int getExitCode() { | ||
| return exitCode; | ||
| } | ||
|
|
||
| public void setExitCode(int exitCode) { | ||
| this.exitCode = exitCode; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.