Skip to content
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

Issue #15236: format some ITs Google Inputs by formatter #15237

Merged
merged 2 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .ci/google-java-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -e

JAR_PATH="$1"

INPUT_PATHS=($(find src/it/resources/com/google/checkstyle/test/ -name "Input*.java" \
| sed "s|src/it/resources/com/google/checkstyle/test/||" \
| grep -v "rule711generalform" | grep -v "rule712paragraphs" | grep -v "rule713atclauses" \
| grep -v "rule72thesummaryfragment" | grep -v "rule73" \
| grep -v "rule64" \
| grep -v "rule528" \
| grep -v "rule53camelcase" \
| grep -v "rule522classnames" \
| grep -v "rule51identifiernames" \
| grep -v "rule41" | grep -v "rule42" | grep -v "rule43onestatement" \
| grep -v "rule44columnlimit" \
| grep -v "rule45" | grep -v "rule461verticalwhitespace" | grep -v "rule462" \
| grep -v "rule48" \
| grep -v "rule3sourcefile" | grep -v "rule331nowildcard" | grep -v "rule332nolinewrap" \
| grep -v "rule333orderingandspacing" \
| grep -v "rule3421overloadsplit" \
| grep -v "rule231filetab" \
))

for INPUT_PATH in "${INPUT_PATHS[@]}"; do
java -jar "$JAR_PATH" --replace src/it/resources/com/google/checkstyle/test/"$INPUT_PATH"
done
49 changes: 49 additions & 0 deletions .github/workflows/google-java-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#####################################################################################
# GitHub Action to format specific files by google-java-format.
#
# Workflow starts when:
# 1) push to master
# 2) PR created or pushed
#
#####################################################################################
name: Google-Java-Format

on:
push:
branches:
- master
pull_request:
branches: '*'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
VERSION: 1.22.0

jobs:
test:
if: github.repository == 'checkstyle/checkstyle'
runs-on: ubuntu-latest
steps:
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'

- name: Checkout Pull Request Code
uses: actions/checkout@v4

- uses: robinraju/release-downloader@v1
with:
repository: 'google/google-java-format'
tag: "v${{env.VERSION}}"
fileName: "google-java-format-${{env.VERSION}}-all-deps.jar"
out-file-path: '.ci-temp'

- name: Run Formatting
run: |
./.ci/google-java-format.sh .ci-temp/google-java-format-${{env.VERSION}}-all-deps.jar
./.ci/validation.sh git-diff
2 changes: 2 additions & 0 deletions config/jsoref-spellchecker/whitelist.words
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ Dorekit
Dorg
DOTALL
doubletag
downloader
doxia
Dpi
Dpmd
Expand Down Expand Up @@ -1141,6 +1142,7 @@ rickgiles
rightcurly
Rl
rnveach
robinraju
romani
romanivanovjr
rp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,50 +101,50 @@ public void specialCharsWithWarn2() {
}

Inner anoInner =
new Inner() {
public String wrongEscapeSequences() {
final String r1 = "\u0008";
final String r2 = "\u0009"; // violation 'Consider using special escape sequence .*'
final String r3 = "\u000csssdfsd";
// violation above 'Consider using special escape sequence .*'
final char r5 = '\012'; // violation 'Consider using special escape sequence .*'
final char r6 = '\u0022'; // violation 'Consider using special escape sequence .*'
final char r7 = '\b';
return "\u000csssdfsd"; // violation 'Consider using special escape sequence .*'
}
new Inner() {
public String wrongEscapeSequences() {
final String r1 = "\u0008";
final String r2 = "\u0009"; // violation 'Consider using special escape sequence .*'
final String r3 = "\u000csssdfsd";
// violation above 'Consider using special escape sequence .*'
final char r5 = '\012'; // violation 'Consider using special escape sequence .*'
final char r6 = '\u0022'; // violation 'Consider using special escape sequence .*'
final char r7 = '\b';
return "\u000csssdfsd"; // violation 'Consider using special escape sequence .*'
}

public void specialCharsWithoutWarn() {
String r1 = "\b";
String r2 = "\t";
String r3 = "\n";
String r4 = "\f";
String r5 = "\r";
String r6 = "\"";
String r7 = "\'";
String r8 = "\\";
}
public void specialCharsWithoutWarn() {
String r1 = "\b";
String r2 = "\t";
String r3 = "\n";
String r4 = "\f";
String r5 = "\r";
String r6 = "\"";
String r7 = "\'";
String r8 = "\\";
}

public void specialCharsWithWarn() {
String r1 = "\\u0008";
String r2 = "\\u0009"; // violation 'Consider using special escape sequence .*'
String r3 = "\\u000a"; // violation 'Consider using special escape sequence .*'
String r4 = "\\u000c"; // violation 'Consider using special escape sequence .*'
String r5 = "\\u000d"; // violation 'Consider using special escape sequence .*'
String r6 = "\\u0022"; // violation 'Consider using special escape sequence .*'
String r7 = "\\u0027"; // violation 'Consider using special escape sequence .*'
String r8 = "\\u005c"; // violation 'Consider using special escape sequence .*'
}
public void specialCharsWithWarn() {
String r1 = "\\u0008";
String r2 = "\\u0009"; // violation 'Consider using special escape sequence .*'
String r3 = "\\u000a"; // violation 'Consider using special escape sequence .*'
String r4 = "\\u000c"; // violation 'Consider using special escape sequence .*'
String r5 = "\\u000d"; // violation 'Consider using special escape sequence .*'
String r6 = "\\u0022"; // violation 'Consider using special escape sequence .*'
String r7 = "\\u0027"; // violation 'Consider using special escape sequence .*'
String r8 = "\\u005c"; // violation 'Consider using special escape sequence .*'
}

public void specialCharsWithWarn2() {
String r1 = "\\010"; // violation 'Consider using special escape sequence .*'
String r2 = "\\011"; // violation 'Consider using special escape sequence .*'
String r3 = "\\012"; // violation 'Consider using special escape sequence .*'
String r4 = "\\014"; // violation 'Consider using special escape sequence .*'
String r5 = "\\015"; // violation 'Consider using special escape sequence .*'
String r6 = "\\042"; // violation 'Consider using special escape sequence .*'
String r7 = "\\047"; // violation 'Consider using special escape sequence .*'
String r8 = "\\134"; // violation 'Consider using special escape sequence .*'
}
};
public void specialCharsWithWarn2() {
String r1 = "\\010"; // violation 'Consider using special escape sequence .*'
String r2 = "\\011"; // violation 'Consider using special escape sequence .*'
String r3 = "\\012"; // violation 'Consider using special escape sequence .*'
String r4 = "\\014"; // violation 'Consider using special escape sequence .*'
String r5 = "\\015"; // violation 'Consider using special escape sequence .*'
String r6 = "\\042"; // violation 'Consider using special escape sequence .*'
String r7 = "\\047"; // violation 'Consider using special escape sequence .*'
String r8 = "\\134"; // violation 'Consider using special escape sequence .*'
}
};
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.google.checkstyle.test. // violation 'package statement should not be line-wrapped.'
chapter3filestructure.rule32packagestatement;
chapter3filestructure.rule32packagestatement;

/** some javadoc. */
public class InputPackageStatement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,26 @@ void method(int i, int j, boolean cond) {
throw new RuntimeException("");
case 6:
continue;
case 7: {
break;
}
case 8: {
return;
}
case 9: {
throw new RuntimeException("");
}
case 10: {
continue;
}
case 11: {
i++;
}
case 7:
{ // violation 'should be on the previous line'
break;
}
case 8:
{ // violation 'should be on the previous line'
return;
}
case 9:
{ // violation 'should be on the previous line'
throw new RuntimeException("");
}
case 10:
{ // violation 'should be on the previous line'
continue;
}
case 11:
{ // violation 'should be on the previous line'
i++;
}
case 12: // violation 'Fall through from previous branch of the switch statement.'
if (false) {
break;
Expand Down Expand Up @@ -152,22 +157,27 @@ void methodFallThru(int i, int j, boolean cond) {
throw new RuntimeException("");
case 6:
continue;
case 7: {
break;
}
case 8: {
return;
}
case 9: {
throw new RuntimeException("");
}
case 10: {
continue;
}
case 11: {
i++;
}
// fallthru
case 7:
{ // violation 'should be on the previous line'
break;
}
case 8:
{ // violation 'should be on the previous line'
return;
}
case 9:
{ // violation 'should be on the previous line'
throw new RuntimeException("");
}
case 10:
{ // violation 'should be on the previous line'
continue;
}
case 11:
{ // violation 'should be on the previous line'
i++;
}
// fallthru
case 12:
if (false) {
break;
Expand Down Expand Up @@ -253,7 +263,8 @@ void methodFallThru(int i, int j, boolean cond) {
}
case 24:
i++;
/* fallthru */ case 25:
// violation below 'incorrect indentation level'
/* fallthru */ case 25:
i++;
break;

Expand Down Expand Up @@ -285,13 +296,15 @@ void methodFallThruCc(int i, int j, boolean cond) {
case 1:
i++;
// fallthru
case 2: {
i++;
}
// fallthru
case 2:
{ // violation 'should be on the previous line'
i++;
}
// fallthru
case 3:
i++;
/* fallthru */ case 4:
// violation below 'incorrect indentation level'
/* fallthru */ case 4:
break;
case 5:
i++;
Expand All @@ -312,7 +325,8 @@ void methodFallThruC(int i, int j, boolean cond) {
/* fallthru */
case 2:
i++;
/* fallthru */ case 3:
// violation below 'incorrect indentation level'
/* fallthru */ case 3:
break;
case 4:
i++;
Expand All @@ -333,7 +347,8 @@ void methodFallThruC2(int i, int j, boolean cond) {
/*fallthru*/
case 2:
i++;
/*fallthru*/ case 3:
// violation below 'incorrect indentation level'
/*fallthru*/ case 3:
break;
case 4:
i++;
Expand All @@ -354,7 +369,8 @@ void methodFallThruOtherWords(int i, int j, boolean cond) {
/* falls through */
case 2:
i++;
/* falls through */ case 3:
// violation below 'incorrect indentation level'
/* falls through */ case 3:
break;
case 4:
i++;
Expand All @@ -375,8 +391,10 @@ void methodFallThruCustomWords(int i, int j, boolean cond) {
/* Continue with next case. */
case 2: // violation 'Fall through from previous branch of the switch statement.'
i++;
/* Continue with next case. */ case 3:
// violation above 'Fall through from previous branch of the switch statement.'
/* Continue with next case. */ case 3:
// 2 violations above:
// 'Fall through from previous branch of the switch statement.'
// 'incorrect indentation level'
break;
case 4:
i++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ void fO() {} // violation 'Method name 'fO' must match pattern'
}

InnerFoo anon =
new InnerFoo() {
void foo() {}
new InnerFoo() {
void foo() {}

void Foo() {} // violation 'Method name 'Foo' must match pattern'
void Foo() {} // violation 'Method name 'Foo' must match pattern'

void fOo() {} // violation 'Method name 'fOo' must match pattern'
void fOo() {} // violation 'Method name 'fOo' must match pattern'

void f0o() {}
void f0o() {}

void f$o() {} // violation 'Method name 'f\$o' must match pattern'
void f$o() {} // violation 'Method name 'f\$o' must match pattern'

void f_oo() {} // violation 'Method name 'f_oo' must match pattern'
void f_oo() {} // violation 'Method name 'f_oo' must match pattern'

void f() {} // violation 'Method name 'f' must match pattern'
void f() {} // violation 'Method name 'f' must match pattern'

void fO() {} // violation 'Method name 'fO' must match pattern'
};
void fO() {} // violation 'Method name 'fO' must match pattern'
};

interface FooIn {
void foo();
Expand Down
Loading