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

[ci] formatting based on current rules #916

Merged
merged 1 commit into from
Jul 14, 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
4 changes: 1 addition & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
<url>scm:git:ssh://git@github.com/revelc/formatter-maven-plugin.git</url>
</site>
</distributionManagement>

<properties>
<formatter.configFile>${project.basedir}/src/main/resources/formatter-maven-plugin/eclipse/java.xml</formatter.configFile>
<formatter.css.skip>true</formatter.css.skip>
Expand All @@ -82,11 +81,10 @@
<impsort.groups>java.,javax.,org.,com.,net.</impsort.groups>
<javadoc.doclint>all</javadoc.doclint>
<maven.compiler.release>17</maven.compiler.release>

<!-- Remove the following after next parent update includes these major updates -->
<maven.site.deploy.skip>false</maven.site.deploy.skip>
<version.maven-fluido-skin>2.0.0-M9</version.maven-fluido-skin>
<version.maven-site-plugin>4.0.0-M15</version.maven-site-plugin>
<maven.site.deploy.skip>false</maven.site.deploy.skip>
</properties>
<dependencyManagement>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static String fixLineEnding(String code, final LineEnding ending) {

/**
* Do format.
*
* <p>
* notice that when calling this function, {@code ending} here MUST equals lineending in config when
* {@link #init(Map, ConfigurationSource)} init.
*
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/net/revelc/code/formatter/FormatterMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,8 @@ protected void doFormatFile(final File file, final ResultCollector rc, final Pro

// Process the result type
if (Result.SKIPPED.equals(result)) {
// Use unchanged count for files that either 'skipFormattingCache' or cache missed but flagged to skip formatting.
// Use unchanged count for files that either 'skipFormattingCache' or cache missed but flagged to skip
// formatting.
rc.unchangedCount++;
} else if (Result.SUCCESS.equals(result)) {
rc.successCount++;
Expand Down Expand Up @@ -1112,7 +1113,10 @@ static class ResultCollector {
/** The skipped count is incremented for cached files that haven't changed since being cached. */
int skippedCount;

/** Use unchanged count for files that either 'skipFormattingCache' or cache missed but flagged to skip formatting. */
/**
* Use unchanged count for files that either 'skipFormattingCache' or cache missed but flagged to skip
* formatting.
*/
int unchangedCount;

/** The read only count. */
Expand Down
36 changes: 18 additions & 18 deletions src/test/java/net/revelc/code/formatter/AbstractFormatterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,16 @@ private void doTestFormat(final Map<String, String> options, final Formatter for
// Set the used output directory for test (either first pass or second pass)
File testOutputDir;
switch (formatCycle) {
case 1:
resourceLocation = AbstractFormatterTest.RESOURCE_LOCATION_PRIMARY;
testOutputDir = AbstractFormatterTest.TEST_OUTPUT_PRIMARY_DIR;
break;
case 2:
resourceLocation = AbstractFormatterTest.RESOURCE_LOCATION_SECONDARY;
testOutputDir = AbstractFormatterTest.TEST_OUTPUT_SECONDARY_DIR;
break;
default:
throw new IllegalStateException("Unrecognized format cycle: " + formatCycle);
case 1:
resourceLocation = AbstractFormatterTest.RESOURCE_LOCATION_PRIMARY;
testOutputDir = AbstractFormatterTest.TEST_OUTPUT_PRIMARY_DIR;
break;
case 2:
resourceLocation = AbstractFormatterTest.RESOURCE_LOCATION_SECONDARY;
testOutputDir = AbstractFormatterTest.TEST_OUTPUT_SECONDARY_DIR;
break;
default:
throw new IllegalStateException("Unrecognized format cycle: " + formatCycle);
}

// Set original file and file to use for test
Expand All @@ -234,14 +234,14 @@ private void doTestFormat(final Map<String, String> options, final Formatter for
// Run assertions on formatted file, if not valid, reject and tester can look at resulting files
// to debug issue.
switch (formatCycle) {
case 1:
Assertions.assertNotEquals(originalCode, formattedCode);
break;
case 2:
Assertions.assertEquals(originalCode, formattedCode);
break;
default:
throw new IllegalStateException("Unrecognized format cycle: " + formatCycle);
case 1:
Assertions.assertNotEquals(originalCode, formattedCode);
break;
case 2:
Assertions.assertEquals(originalCode, formattedCode);
break;
default:
throw new IllegalStateException("Unrecognized format cycle: " + formatCycle);
}

// We are hashing this as set in stone in case for some reason our source file changes unexpectedly.
Expand Down
6 changes: 0 additions & 6 deletions src/test/java/net/revelc/code/formatter/LineEndingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class LineEndingTest {

/**
* Test successfully determining CRLF line ending.
*
*/
@Test
void test_success_read_line_endings_crlf() {
Expand All @@ -35,7 +34,6 @@ void test_success_read_line_endings_crlf() {

/**
* Test successfully determining LF line ending.
*
*/
@Test
void test_success_read_line_endings_lf() {
Expand All @@ -46,7 +44,6 @@ void test_success_read_line_endings_lf() {

/**
* Test successfully determining CR line ending.
*
*/
@Test
void test_success_read_line_endings_cr() {
Expand All @@ -57,7 +54,6 @@ void test_success_read_line_endings_cr() {

/**
* Test successfully determining LF line ending with mixed endings.
*
*/
@Test
void test_success_read_line_endings_mixed_lf() {
Expand All @@ -68,7 +64,6 @@ void test_success_read_line_endings_mixed_lf() {

/**
* Test successfully determining AUTO line ending with mixed endings and no clear majority.
*
*/
@Test
void test_success_read_line_endings_mixed_auto() {
Expand All @@ -79,7 +74,6 @@ void test_success_read_line_endings_mixed_auto() {

/**
* Test successfully determining AUTO line ending with no endings.
*
*/
@Test
void test_success_read_line_endings_none_auto() {
Expand Down
1 change: 0 additions & 1 deletion src/test/java/net/revelc/code/formatter/TimeUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class TimeUtilTest {

/**
* Test print duration.
*
*/
@Test
void testPrintDuration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class CssFormatterTest extends AbstractFormatterTest {

/**
* Test do format file.
*
*/
@Test
void testDoFormatFile() {
Expand All @@ -43,7 +42,6 @@ void testDoFormatFile() {

/**
* Test is initialized.
*
*/
@Test
void testIsInitialized() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class HTMLFormatterTest extends AbstractFormatterTest {

/**
* Test do format file.
*
*/
@Test
void testDoFormatFile() {
Expand All @@ -43,7 +42,6 @@ void testDoFormatFile() {

/**
* Test is initialized.
*
*/
@Test
void testIsInitialized() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class JavaFormatterTest extends AbstractFormatterTest {

/**
* Test do format file.
*
*/
@Test
void testDoFormatFile() {
Expand All @@ -42,7 +41,6 @@ void testDoFormatFile() {

/**
* Test do format file keep line feed LF.
*
*/
@Test
void testDoFormatFileKeepLineFeedLF() {
Expand All @@ -52,7 +50,6 @@ void testDoFormatFileKeepLineFeedLF() {

/**
* Test do format file keep line feed CR.
*
*/
@Test
void testDoFormatFileKeepLineFeedCR() {
Expand All @@ -62,7 +59,6 @@ void testDoFormatFileKeepLineFeedCR() {

/**
* Test do format file keep line feed CRLF.
*
*/
@Test
void testDoFormatFileKeepLineFeedCRLF() {
Expand All @@ -73,7 +69,6 @@ void testDoFormatFileKeepLineFeedCRLF() {

/**
* Test is initialized.
*
*/
@Test
void testIsInitialized() {
Expand All @@ -86,7 +81,6 @@ void testIsInitialized() {

/**
* Test do format file with exclusions.
*
*/
@Test
void testDoFormatFileWithExclusions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class JavascriptFormatterTest extends AbstractFormatterTest {

/**
* Test do format file.
*
*/
@Test
void testDoFormatFile() {
Expand All @@ -42,7 +41,6 @@ void testDoFormatFile() {

/**
* Test is initialized.
*
*/
@Test
void testIsInitialized() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class JsonFormatterTest extends AbstractFormatterTest {

/**
* Test do format file.
*
*/
@Test
void testDoFormatFile() {
Expand Down Expand Up @@ -64,7 +63,6 @@ void testIsInitialized() {

/**
* Test do format file with config.
*
*/
@Test
void testDoFormatFileWithConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class XMLFormatterTest extends AbstractFormatterTest {

/**
* Test do format file.
*
*/
@Test
void testDoFormatFile() {
Expand All @@ -45,7 +44,6 @@ void testDoFormatFile() {

/**
* Test is initialized.
*
*/
@Test
void testIsInitialized() {
Expand Down