Skip to content

Issue #17285: Add non-compilable resources to google-java-format.sh#17288

Merged
romani merged 1 commit into
checkstyle:masterfrom
mohitsatr:non-compilable-1
Jul 6, 2025
Merged

Issue #17285: Add non-compilable resources to google-java-format.sh#17288
romani merged 1 commit into
checkstyle:masterfrom
mohitsatr:non-compilable-1

Conversation

@mohitsatr

Copy link
Copy Markdown
Member

resolves #17285

  • Added resources-noncompilable path to the google-java-format.sh
  • Created missing InputFormatted...java inputs and tests

Comment thread .ci/google-java-format.sh Outdated
| grep -v "rule527localvariablenames/InputPatternVariableNameEnhancedInstanceofTestDefault.java" \
))

echo "${NON_COMPILABLE_INPUT_PATHS[@]}"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is just for testing. will remove it later

@Zopsss

Zopsss commented Jun 29, 2025

Copy link
Copy Markdown
Member

https://github.com/checkstyle/checkstyle/actions/runs/15942039767/job/44971356845#step:5:1

Is formatter not able to support the newer syntax?

Can you try to format these files locally and show us the results? @mohitsatr

@mohitsatr

mohitsatr commented Jun 30, 2025

Copy link
Copy Markdown
Member Author

@Zopsss @romani
CI is passing correctly locally.

$ ./.ci/google-java-format.sh  ../../test/testing/google-java-format-1.27.0-all-deps.jar 
Checking that all excluded java files in this script have matching InputFormatted* file:
Excluded Input files matches to InputFormatted files.
Formatting all Input files file at src/it/resources/com/google/checkstyle/test :
Formatting all Non-compatiable Input files file at src/it/resources-noncompilable/com/google/checkstyle/test :


chapter3filestructure/rule3421overloadsplit/InputOverloadsNeverSplitRecords.java chapter4formatting/rule462horizontalwhitespace/InputFormattedWhitespaceAroundArrow.java chapter4formatting/rule462horizontalwhitespace/InputFormattedWhitespaceAroundWhen.java chapter4formatting/rule462horizontalwhitespace/InputWhitespaceAroundArrowCorrect.java chapter4formatting/rule4841indentation/InputFormattedCatchParametersOnNewLine.java chapter4formatting/rule4841indentation/InputFormattedLambdaAndChildOnTheSameLine.java chapter4formatting/rule4841indentation/InputFormattedLambdaChild.java chapter4formatting/rule4841indentation/InputFormattedSingleSwitchStatementWithoutCurly.java chapter4formatting/rule4841indentation/InputFormattedSwitchOnStartOfTheLine.java chapter4formatting/rule4841indentation/InputFormattedSwitchWrappingIndentation.java chapter4formatting/rule4841indentation/InputLambdaChildCorrect.java chapter4formatting/rule4841indentation/InputMultilineStatementsCorrect.java chapter4formatting/rule4841indentation/InputSingleSwitchStatementWithoutCurlyCorrect.java chapter4formatting/rule4841indentation/InputSwitchOnStartOfTheLineCorrect.java chapter4formatting/rule4841indentation/InputSwitchWrappingIndentationCorrect.java chapter5naming/rule526parameternames/InputFormattedRecordComponentName.java chapter5naming/rule527localvariablenames/InputFormattedPatternVariableNameEnhancedInstanceofTestDefault.java chapter5naming/rule528typevariablenames/InputRecordTypeParameterName.java

and formatter too is working as expected.

$ java -jar google-java-format-1.27.0-all-deps.jar src/it/resources-noncompilable/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/InputWhitespaceAroundArrowCorrect.java > FormattedCode.java 

$ diff -Naru src/it/resources-noncompilable/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/InputWhitespaceAroundArrowCorrect.java FormattedCode.java

@Zopsss

Zopsss commented Jun 30, 2025

Copy link
Copy Markdown
Member

@mohitsatr please push the changes

@mohitsatr

mohitsatr commented Jun 30, 2025

Copy link
Copy Markdown
Member Author

no changes are made on the local. I just tried formatting the file and ran google-formatter CI job. neither gave any problem.

Edit: please ignore the above. CI did make some formatting changes.

@romani

romani commented Jul 2, 2025

Copy link
Copy Markdown
Member

@mohitsatr ,

https://github.com/checkstyle/checkstyle/actions/runs/15969982936/job/45038817056?pr=17288#step:5:15

 src/it/resources-noncompilable/com/google/checkstyle/test/chapter4formatting/
rule462horizontalwhitespace/InputWhitespaceAroundArrowCorrect.java:16:20: 
error: : or -> expected
      case String s when (s.equals("a")) -> {}

looks like we leaked bad files. "non-compiled" usually means non-compiled by jdk11 but compiled by jdk21. And we have a just another gap here.

Please fix compilation error.

We will improve for all other files in scope of #17309
and better to make it sooner to not deal with non-compiled files, as they can make checkstyle's java parser to be weird.

@Zopsss

Zopsss commented Jul 5, 2025

Copy link
Copy Markdown
Member

@mohitsatr any updates on this?

@mohitsatr mohitsatr force-pushed the non-compilable-1 branch 3 times, most recently from 5e42e62 to 4180b41 Compare July 6, 2025 05:30
@mohitsatr

Copy link
Copy Markdown
Member Author

@romani @Zopsss
the reason for failure is compilation by wrong javac

// non-compiled with javac: Compilable with Java21
package com.google.checkstyle.test.chapter4formatting.rule462horizontalwhitespace;

the file is compilable by javac21, but is getting tested on javac17
https://github.com/checkstyle/checkstyle/actions/runs/16095731963/job/45418341693?pr=17288

@romani romani force-pushed the non-compilable-1 branch from 4180b41 to 379dbfa Compare July 6, 2025 12:51
@romani

romani commented Jul 6, 2025

Copy link
Copy Markdown
Member

workflow is updated to use jdk21

@romani romani merged commit 8c033e2 into checkstyle:master Jul 6, 2025
118 checks passed
@mohitsatr mohitsatr deleted the non-compilable-1 branch July 7, 2025 02:54
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.

Google-style: Add resources-noncompilable inputs to the google-java-format.sh

3 participants