From 96993c25a916536a845bd36af1151aafbe792e71 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 23 Sep 2025 19:49:27 +0000
Subject: [PATCH 1/5] Initial plan
From c84f123f303830f3f8091550a301aaaffc6fec41 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 23 Sep 2025 19:57:24 +0000
Subject: [PATCH 2/5] Implement print statement usage policy enforcement in
Maven build
Co-authored-by: khatchad <2048831+khatchad@users.noreply.github.com>
---
README.md | 10 +++
docs/PRINT_STATEMENT_POLICY.md | 114 ++++++++++++++++++++++++++++++
pom.xml | 29 ++++++++
scripts/check-print-statements.sh | 78 ++++++++++++++++++++
scripts/test-print-checker.sh | 66 +++++++++++++++++
5 files changed, 297 insertions(+)
create mode 100644 docs/PRINT_STATEMENT_POLICY.md
create mode 100755 scripts/check-print-statements.sh
create mode 100755 scripts/test-print-checker.sh
diff --git a/README.md b/README.md
index 1a03d69f6..6e219bf4b 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,16 @@ This is the top level repository for Ariadne code. More information on using the
Since it is built using [WALA], you need to have WALA on your system to use it. Instructions on building this project can be found in [CONTRIBUTING.md].
+## Code Quality Standards
+
+This project enforces several code quality standards:
+
+- **Print Statement Policy**: Print statements (`System.out`, `System.err`) should only be used in CLI driver classes. See [Print Statement Policy](docs/PRINT_STATEMENT_POLICY.md) for details.
+- **Code Formatting**: Java code is formatted using Spotless with Google Java Format.
+- **Python Formatting**: Python code is formatted using Black.
+
+The build will fail if these standards are not met.
+
To test, for example, run `TestCalls` in the `com.ibm.wala.cast.python.test` project.
[WALA]: https://github.com/wala/WALA
diff --git a/docs/PRINT_STATEMENT_POLICY.md b/docs/PRINT_STATEMENT_POLICY.md
new file mode 100644
index 000000000..c6f1d08c0
--- /dev/null
+++ b/docs/PRINT_STATEMENT_POLICY.md
@@ -0,0 +1,114 @@
+# Print Statement Usage Policy
+
+This project enforces a policy that prevents inappropriate usage of `System.out.println()` and `System.err.println()` in non-CLI code. Print statements should only be used in CLI driver classes for user-facing output.
+
+## Policy
+
+- **Allowed**: Print statements in CLI driver classes (under `/driver/` packages) and test classes
+- **Allowed**: Print statements in main methods of utility/demo classes (e.g., parser demos)
+- **Not Allowed**: Print statements in core library code, analysis code, or other non-CLI components
+
+For non-CLI code, use `java.util.logging.Logger` instead of print statements.
+
+## Build Integration
+
+The build automatically checks for inappropriate print statement usage during the `validate` phase:
+
+```bash
+# This will fail if inappropriate print statements are found
+mvn validate
+
+# This will succeed only if no violations are detected
+mvn validate -Dskip.print.check=false
+```
+
+## Bypassing the Check
+
+During development or when working on refactoring print statements (e.g., issue #331), you can skip the check:
+
+```bash
+# Skip the print statement check
+mvn validate -Dskip.print.check=true
+
+# Or set it permanently in your local settings
+mvn clean install -Dskip.print.check=true
+```
+
+## Fixing Violations
+
+If the build fails due to inappropriate print statements:
+
+1. **For debug/info messages**: Replace with appropriate logging:
+ ```java
+ // Bad
+ System.err.println("Debug info: " + value);
+
+ // Good
+ private static final Logger LOGGER = Logger.getLogger(MyClass.class.getName());
+ LOGGER.fine("Debug info: " + value);
+ ```
+
+2. **For error messages**: Use logging with appropriate levels:
+ ```java
+ // Bad
+ System.err.println("Error occurred: " + exception.getMessage());
+
+ // Good
+ LOGGER.severe("Error occurred: " + exception.getMessage());
+ ```
+
+3. **For CLI output**: Move the code to a driver class or ensure it's in an appropriate location
+
+## Script Details
+
+The check is implemented by `scripts/check-print-statements.sh` which:
+
+- Scans all Java files for `System.out` and `System.err` usage
+- Excludes files in `/driver/`, `/test/`, and `/test-source/` directories
+- Allows print statements in main methods of specific utility classes
+- Fails the build if violations are found
+
+## Examples
+
+### ✅ Allowed Usage
+
+```java
+// CLI driver class
+public class Ariadne {
+ public static void main(String[] args) {
+ System.out.println("Analysis complete."); // OK - CLI output
+ }
+}
+
+// Test class
+public class TestParser {
+ public void testMethod() {
+ System.err.println("Debug output"); // OK - test code
+ }
+}
+
+// Demo main method
+public class PythonFileParser {
+ public static void main(String[] args) {
+ System.err.println(script); // OK - demo/utility main method
+ }
+}
+```
+
+### ❌ Prohibited Usage
+
+```java
+// Core library code
+public class PythonParser {
+ public void parseCode() {
+ System.err.println("Parsing..."); // NOT OK - use LOGGER.fine() instead
+ }
+}
+
+// Analysis engine
+public class AnalysisEngine {
+ public void analyze() {
+ System.out.println("Found result"); // NOT OK - use LOGGER.info() instead
+ }
+}
+```
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 5ce0947b8..fcd9f973d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,6 +32,7 @@
./logging.properties
0.8.13
+ false
@@ -252,8 +253,36 @@
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+ 3.1.0
+
+
+ check-print-statements
+ validate
+
+ run
+
+
+ ${skip.print.check}
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
diff --git a/scripts/check-print-statements.sh b/scripts/check-print-statements.sh
new file mode 100755
index 000000000..fdfc86502
--- /dev/null
+++ b/scripts/check-print-statements.sh
@@ -0,0 +1,78 @@
+#!/bin/bash
+
+# Script to check for inappropriate print statement usage
+# Exits with code 1 if inappropriate print statements are found
+
+set -e
+
+# Define allowed directories/patterns for print statements
+ALLOWED_PATTERNS=(
+ "/driver/" # CLI driver classes
+ "/test/" # Test classes
+ "/test-source/" # Test source directories
+)
+
+# Files with legitimate print usage for demonstration/main methods
+LEGITIMATE_FILES=(
+ "PythonFileParser.java" # main method for demo
+ "PythonModuleParser.java" # main method for demo
+)
+
+# Create grep pattern to exclude allowed directories
+EXCLUDE_PATTERN=""
+for pattern in "${ALLOWED_PATTERNS[@]}"; do
+ if [ -n "$EXCLUDE_PATTERN" ]; then
+ EXCLUDE_PATTERN="$EXCLUDE_PATTERN|$pattern"
+ else
+ EXCLUDE_PATTERN="$pattern"
+ fi
+done
+
+echo "Checking for inappropriate print statement usage..."
+echo "Allowed patterns: ${ALLOWED_PATTERNS[*]}"
+echo "Legitimate files: ${LEGITIMATE_FILES[*]}"
+
+# Find Java files with System.out or System.err that are NOT in allowed directories
+ALL_VIOLATIONS=$(find . -name "*.java" -type f | grep -vE "($EXCLUDE_PATTERN)" | xargs grep -l "System\.\(out\|err\)" 2>/dev/null || true)
+
+# Filter out legitimate files
+VIOLATIONS=""
+for file in $ALL_VIOLATIONS; do
+ is_legitimate=false
+ for legit_file in "${LEGITIMATE_FILES[@]}"; do
+ if [[ "$file" == *"$legit_file" ]]; then
+ # Check if it's only in main method
+ if grep -q "public static void main" "$file" && grep -A 20 "public static void main" "$file" | grep -q "System\.\(out\|err\)"; then
+ is_legitimate=true
+ break
+ fi
+ fi
+ done
+
+ if [ "$is_legitimate" = false ]; then
+ if [ -n "$VIOLATIONS" ]; then
+ VIOLATIONS="$VIOLATIONS\n$file"
+ else
+ VIOLATIONS="$file"
+ fi
+ fi
+done
+
+if [ -n "$VIOLATIONS" ]; then
+ echo "ERROR: Found inappropriate print statement usage in the following files:"
+ echo -e "$VIOLATIONS"
+ echo ""
+ echo "Print statements should only be used in CLI driver classes."
+ echo "For non-CLI code, please use java.util.logging.Logger instead."
+ echo ""
+ echo "Files with violations:"
+ for file in $(echo -e "$VIOLATIONS"); do
+ echo " $file:"
+ grep -n "System\.\(out\|err\)" "$file" | head -3
+ echo ""
+ done
+ exit 1
+else
+ echo "✓ No inappropriate print statement usage found"
+ exit 0
+fi
\ No newline at end of file
diff --git a/scripts/test-print-checker.sh b/scripts/test-print-checker.sh
new file mode 100755
index 000000000..336faa182
--- /dev/null
+++ b/scripts/test-print-checker.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+# Test script to validate that the print statement checker works correctly
+
+set -e
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
+TEMP_DIR="/tmp/print-check-test"
+
+echo "Testing print statement checker..."
+
+# Clean up any previous test
+rm -rf "$TEMP_DIR"
+mkdir -p "$TEMP_DIR"
+
+# Create a test Java file with violations
+cat > "$TEMP_DIR/TestViolation.java" << 'EOF'
+package test;
+
+public class TestViolation {
+ public void method() {
+ System.out.println("This should be flagged");
+ }
+}
+EOF
+
+# Create a test Java file without violations (in driver package)
+mkdir -p "$TEMP_DIR/driver"
+cat > "$TEMP_DIR/driver/TestDriver.java" << 'EOF'
+package test.driver;
+
+public class TestDriver {
+ public static void main(String[] args) {
+ System.out.println("This is OK - CLI output");
+ }
+}
+EOF
+
+# Copy the checker script
+cp "$PROJECT_ROOT/scripts/check-print-statements.sh" "$TEMP_DIR/"
+
+# Test 1: Should find violations
+echo "Test 1: Testing with violations..."
+cd "$TEMP_DIR"
+if ./check-print-statements.sh; then
+ echo "ERROR: Expected script to fail but it passed"
+ exit 1
+else
+ echo "✓ Script correctly detected violations"
+fi
+
+# Test 2: Remove violations and test again
+rm TestViolation.java
+echo "Test 2: Testing without violations..."
+if ./check-print-statements.sh; then
+ echo "✓ Script correctly passed when no violations found"
+else
+ echo "ERROR: Expected script to pass but it failed"
+ exit 1
+fi
+
+echo "✓ All tests passed!"
+
+# Clean up
+rm -rf "$TEMP_DIR"
\ No newline at end of file
From a059fbb037e1471edd086e5577130c878fc1bae5 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 23 Sep 2025 19:58:44 +0000
Subject: [PATCH 3/5] Add print statement policy documentation to
CONTRIBUTING.md and finalize implementation
Co-authored-by: khatchad <2048831+khatchad@users.noreply.github.com>
---
CONTRIBUTING.md | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 611e7d388..b08e22b85 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -36,4 +36,21 @@ You must install the `jython-dev.jar` to your local maven repository.
Build and install to your local Maven repo: `mvn install`
+## Code Quality Standards
+
+This project enforces code quality standards during the build process:
+
+### Print Statement Policy
+
+Print statements (`System.out.println`, `System.err.println`) are only allowed in CLI driver classes. The build will fail if inappropriate print statements are detected in core library code.
+
+- **To fix violations**: Replace print statements with appropriate logging using `java.util.logging.Logger`
+- **To skip check during development**: Use `mvn install -Dskip.print.check=true`
+- **For detailed policy**: See [Print Statement Policy](docs/PRINT_STATEMENT_POLICY.md)
+
+### Code Formatting
+
+- **Java**: Uses Spotless with Google Java Format - run `mvn spotless:apply` to auto-fix
+- **Python**: Uses Black - run `black .` to auto-fix
+
[SO post]: https://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-to-a-maven-project#answer-4955695
From c8066ab801f539db63c021062570889538080c45 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 23 Sep 2025 20:17:18 +0000
Subject: [PATCH 4/5] Replace bash script with checkstyle-based print statement
enforcement and update policy to include test classes
Co-authored-by: khatchad <2048831+khatchad@users.noreply.github.com>
---
CONTRIBUTING.md | 2 +-
README.md | 2 +-
checkstyle-suppressions.xml | 13 +++++
checkstyle.xml | 24 +++++++++
docs/PRINT_STATEMENT_POLICY.md | 85 +++++++++++++++++--------------
pom.xml | 32 +++++++-----
scripts/check-print-statements.sh | 78 ----------------------------
scripts/test-print-checker.sh | 66 ------------------------
8 files changed, 106 insertions(+), 196 deletions(-)
create mode 100644 checkstyle-suppressions.xml
create mode 100644 checkstyle.xml
delete mode 100755 scripts/check-print-statements.sh
delete mode 100755 scripts/test-print-checker.sh
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index b08e22b85..32e70980d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -42,7 +42,7 @@ This project enforces code quality standards during the build process:
### Print Statement Policy
-Print statements (`System.out.println`, `System.err.println`) are only allowed in CLI driver classes. The build will fail if inappropriate print statements are detected in core library code.
+Print statements (`System.out.println`, `System.err.println`) are only allowed in CLI driver classes. The build uses Maven Checkstyle plugin to enforce this policy and will fail if inappropriate print statements are detected in core library code or test classes.
- **To fix violations**: Replace print statements with appropriate logging using `java.util.logging.Logger`
- **To skip check during development**: Use `mvn install -Dskip.print.check=true`
diff --git a/README.md b/README.md
index 6e219bf4b..3af2d4f63 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ Since it is built using [WALA], you need to have WALA on your system to use it.
This project enforces several code quality standards:
-- **Print Statement Policy**: Print statements (`System.out`, `System.err`) should only be used in CLI driver classes. See [Print Statement Policy](docs/PRINT_STATEMENT_POLICY.md) for details.
+- **Print Statement Policy**: Print statements (`System.out`, `System.err`) should only be used in CLI driver classes. See [Print Statement Policy](docs/PRINT_STATEMENT_POLICY.md) for details. Enforced via Maven Checkstyle plugin.
- **Code Formatting**: Java code is formatted using Spotless with Google Java Format.
- **Python Formatting**: Python code is formatted using Black.
diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml
new file mode 100644
index 000000000..31b0d828b
--- /dev/null
+++ b/checkstyle-suppressions.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/checkstyle.xml b/checkstyle.xml
new file mode 100644
index 000000000..3c8f841c5
--- /dev/null
+++ b/checkstyle.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/PRINT_STATEMENT_POLICY.md b/docs/PRINT_STATEMENT_POLICY.md
index c6f1d08c0..2a2f3331d 100644
--- a/docs/PRINT_STATEMENT_POLICY.md
+++ b/docs/PRINT_STATEMENT_POLICY.md
@@ -4,15 +4,15 @@ This project enforces a policy that prevents inappropriate usage of `System.out.
## Policy
-- **Allowed**: Print statements in CLI driver classes (under `/driver/` packages) and test classes
+- **Allowed**: Print statements in CLI driver classes (under `/driver/` packages)
- **Allowed**: Print statements in main methods of utility/demo classes (e.g., parser demos)
-- **Not Allowed**: Print statements in core library code, analysis code, or other non-CLI components
+- **Not Allowed**: Print statements in core library code, analysis code, test classes, or other components
-For non-CLI code, use `java.util.logging.Logger` instead of print statements.
+For all non-CLI code, including test classes, use `java.util.logging.Logger` instead of print statements.
## Build Integration
-The build automatically checks for inappropriate print statement usage during the `validate` phase:
+The build automatically checks for inappropriate print statement usage during the `validate` phase using Maven Checkstyle plugin:
```bash
# This will fail if inappropriate print statements are found
@@ -39,32 +39,32 @@ mvn clean install -Dskip.print.check=true
If the build fails due to inappropriate print statements:
1. **For debug/info messages**: Replace with appropriate logging:
- ```java
- // Bad
- System.err.println("Debug info: " + value);
-
- // Good
- private static final Logger LOGGER = Logger.getLogger(MyClass.class.getName());
- LOGGER.fine("Debug info: " + value);
- ```
+```java
+// Bad
+System.err.println("Debug info: " + value);
+
+// Good
+private static final Logger LOGGER = Logger.getLogger(MyClass.class.getName());
+LOGGER.fine("Debug info: " + value);
+```
2. **For error messages**: Use logging with appropriate levels:
- ```java
- // Bad
- System.err.println("Error occurred: " + exception.getMessage());
-
- // Good
- LOGGER.severe("Error occurred: " + exception.getMessage());
- ```
+```java
+// Bad
+System.err.println("Error occurred: " + exception.getMessage());
+
+// Good
+LOGGER.severe("Error occurred: " + exception.getMessage());
+```
3. **For CLI output**: Move the code to a driver class or ensure it's in an appropriate location
## Script Details
-The check is implemented by `scripts/check-print-statements.sh` which:
+The check is implemented using Maven Checkstyle plugin with a custom configuration that:
-- Scans all Java files for `System.out` and `System.err` usage
-- Excludes files in `/driver/`, `/test/`, and `/test-source/` directories
+- Scans all Java files (including test files) for `System.out` and `System.err` usage
+- Excludes files in `/driver/` directories
- Allows print statements in main methods of specific utility classes
- Fails the build if violations are found
@@ -75,23 +75,25 @@ The check is implemented by `scripts/check-print-statements.sh` which:
```java
// CLI driver class
public class Ariadne {
- public static void main(String[] args) {
- System.out.println("Analysis complete."); // OK - CLI output
- }
+ public static void main(String[] args) {
+ System.out.println("Analysis complete."); // OK - CLI output
+ }
}
// Test class
public class TestParser {
- public void testMethod() {
- System.err.println("Debug output"); // OK - test code
- }
+ private static final Logger LOGGER = Logger.getLogger(TestParser.class.getName());
+
+ public void testMethod() {
+ LOGGER.info("Debug output"); // OK - using logging
+ }
}
// Demo main method
public class PythonFileParser {
- public static void main(String[] args) {
- System.err.println(script); // OK - demo/utility main method
- }
+ public static void main(String[] args) {
+ System.err.println(script); // OK - demo/utility main method
+ }
}
```
@@ -100,15 +102,22 @@ public class PythonFileParser {
```java
// Core library code
public class PythonParser {
- public void parseCode() {
- System.err.println("Parsing..."); // NOT OK - use LOGGER.fine() instead
- }
+ public void parseCode() {
+ System.err.println("Parsing..."); // NOT OK - use LOGGER.fine() instead
+ }
}
// Analysis engine
public class AnalysisEngine {
- public void analyze() {
- System.out.println("Found result"); // NOT OK - use LOGGER.info() instead
- }
+ public void analyze() {
+ System.out.println("Found result"); // NOT OK - use LOGGER.info() instead
+ }
}
-```
\ No newline at end of file
+
+// Test class
+public class TestAnalysis {
+ public void testMethod() {
+ System.err.println("Debug info"); // NOT OK - use LOGGER.info() instead
+ }
+}
+```
diff --git a/pom.xml b/pom.xml
index fcd9f973d..dc7e4ed1f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,6 +28,7 @@
1.6.13-SNAPSHOT
2.46.1
3.5.4
+ 10.20.1
both
./logging.properties
0.8.13
@@ -255,23 +256,30 @@
org.apache.maven.plugins
- maven-antrun-plugin
- 3.1.0
+ maven-checkstyle-plugin
+ 3.5.0
+
+ checkstyle.xml
+ true
+ UTF-8
+ true
+ true
+ ${skip.print.check}
+
+
+
+ com.puppycrawl.tools
+ checkstyle
+ ${checkstyle.version}
+
+
check-print-statements
validate
- run
+ check
-
- ${skip.print.check}
-
-
-
-
-
-
@@ -280,7 +288,7 @@
org.apache.maven.plugins
- maven-antrun-plugin
+ maven-checkstyle-plugin
diff --git a/scripts/check-print-statements.sh b/scripts/check-print-statements.sh
deleted file mode 100755
index fdfc86502..000000000
--- a/scripts/check-print-statements.sh
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/bin/bash
-
-# Script to check for inappropriate print statement usage
-# Exits with code 1 if inappropriate print statements are found
-
-set -e
-
-# Define allowed directories/patterns for print statements
-ALLOWED_PATTERNS=(
- "/driver/" # CLI driver classes
- "/test/" # Test classes
- "/test-source/" # Test source directories
-)
-
-# Files with legitimate print usage for demonstration/main methods
-LEGITIMATE_FILES=(
- "PythonFileParser.java" # main method for demo
- "PythonModuleParser.java" # main method for demo
-)
-
-# Create grep pattern to exclude allowed directories
-EXCLUDE_PATTERN=""
-for pattern in "${ALLOWED_PATTERNS[@]}"; do
- if [ -n "$EXCLUDE_PATTERN" ]; then
- EXCLUDE_PATTERN="$EXCLUDE_PATTERN|$pattern"
- else
- EXCLUDE_PATTERN="$pattern"
- fi
-done
-
-echo "Checking for inappropriate print statement usage..."
-echo "Allowed patterns: ${ALLOWED_PATTERNS[*]}"
-echo "Legitimate files: ${LEGITIMATE_FILES[*]}"
-
-# Find Java files with System.out or System.err that are NOT in allowed directories
-ALL_VIOLATIONS=$(find . -name "*.java" -type f | grep -vE "($EXCLUDE_PATTERN)" | xargs grep -l "System\.\(out\|err\)" 2>/dev/null || true)
-
-# Filter out legitimate files
-VIOLATIONS=""
-for file in $ALL_VIOLATIONS; do
- is_legitimate=false
- for legit_file in "${LEGITIMATE_FILES[@]}"; do
- if [[ "$file" == *"$legit_file" ]]; then
- # Check if it's only in main method
- if grep -q "public static void main" "$file" && grep -A 20 "public static void main" "$file" | grep -q "System\.\(out\|err\)"; then
- is_legitimate=true
- break
- fi
- fi
- done
-
- if [ "$is_legitimate" = false ]; then
- if [ -n "$VIOLATIONS" ]; then
- VIOLATIONS="$VIOLATIONS\n$file"
- else
- VIOLATIONS="$file"
- fi
- fi
-done
-
-if [ -n "$VIOLATIONS" ]; then
- echo "ERROR: Found inappropriate print statement usage in the following files:"
- echo -e "$VIOLATIONS"
- echo ""
- echo "Print statements should only be used in CLI driver classes."
- echo "For non-CLI code, please use java.util.logging.Logger instead."
- echo ""
- echo "Files with violations:"
- for file in $(echo -e "$VIOLATIONS"); do
- echo " $file:"
- grep -n "System\.\(out\|err\)" "$file" | head -3
- echo ""
- done
- exit 1
-else
- echo "✓ No inappropriate print statement usage found"
- exit 0
-fi
\ No newline at end of file
diff --git a/scripts/test-print-checker.sh b/scripts/test-print-checker.sh
deleted file mode 100755
index 336faa182..000000000
--- a/scripts/test-print-checker.sh
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/bash
-
-# Test script to validate that the print statement checker works correctly
-
-set -e
-
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
-TEMP_DIR="/tmp/print-check-test"
-
-echo "Testing print statement checker..."
-
-# Clean up any previous test
-rm -rf "$TEMP_DIR"
-mkdir -p "$TEMP_DIR"
-
-# Create a test Java file with violations
-cat > "$TEMP_DIR/TestViolation.java" << 'EOF'
-package test;
-
-public class TestViolation {
- public void method() {
- System.out.println("This should be flagged");
- }
-}
-EOF
-
-# Create a test Java file without violations (in driver package)
-mkdir -p "$TEMP_DIR/driver"
-cat > "$TEMP_DIR/driver/TestDriver.java" << 'EOF'
-package test.driver;
-
-public class TestDriver {
- public static void main(String[] args) {
- System.out.println("This is OK - CLI output");
- }
-}
-EOF
-
-# Copy the checker script
-cp "$PROJECT_ROOT/scripts/check-print-statements.sh" "$TEMP_DIR/"
-
-# Test 1: Should find violations
-echo "Test 1: Testing with violations..."
-cd "$TEMP_DIR"
-if ./check-print-statements.sh; then
- echo "ERROR: Expected script to fail but it passed"
- exit 1
-else
- echo "✓ Script correctly detected violations"
-fi
-
-# Test 2: Remove violations and test again
-rm TestViolation.java
-echo "Test 2: Testing without violations..."
-if ./check-print-statements.sh; then
- echo "✓ Script correctly passed when no violations found"
-else
- echo "ERROR: Expected script to pass but it failed"
- exit 1
-fi
-
-echo "✓ All tests passed!"
-
-# Clean up
-rm -rf "$TEMP_DIR"
\ No newline at end of file
From e43362bac5b9a7bf1681ff305263946f01270e10 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 23 Sep 2025 20:47:56 +0000
Subject: [PATCH 5/5] Fix whitespace formatting violations in documentation and
XML files
Co-authored-by: khatchad <2048831+khatchad@users.noreply.github.com>
---
checkstyle-suppressions.xml | 14 ++++++--------
checkstyle.xml | 33 +++++++++++++++------------------
docs/PRINT_STATEMENT_POLICY.md | 2 +-
pom.xml | 2 +-
4 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml
index 31b0d828b..345b5daf6 100644
--- a/checkstyle-suppressions.xml
+++ b/checkstyle-suppressions.xml
@@ -2,12 +2,10 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
diff --git a/checkstyle.xml b/checkstyle.xml
index 3c8f841c5..74b263696 100644
--- a/checkstyle.xml
+++ b/checkstyle.xml
@@ -2,23 +2,20 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
diff --git a/docs/PRINT_STATEMENT_POLICY.md b/docs/PRINT_STATEMENT_POLICY.md
index 2a2f3331d..634dbb60e 100644
--- a/docs/PRINT_STATEMENT_POLICY.md
+++ b/docs/PRINT_STATEMENT_POLICY.md
@@ -83,7 +83,7 @@ public class Ariadne {
// Test class
public class TestParser {
private static final Logger LOGGER = Logger.getLogger(TestParser.class.getName());
-
+
public void testMethod() {
LOGGER.info("Debug output"); // OK - using logging
}
diff --git a/pom.xml b/pom.xml
index dc7e4ed1f..8cf05cbd4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -276,10 +276,10 @@
check-print-statements
- validate
check
+ validate