Skip to content

Commit dd8c8dc

Browse files
authored
Merge pull request #77 from embulk/checkstyle-9.3
Checkstyle with checkstyle 9.3
2 parents 5616a11 + 62ed4d6 commit dd8c8dc

20 files changed

Lines changed: 846 additions & 67 deletions

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,13 @@ task jruby9_2_9Test(type: Test, description: "Runs tests with JRuby 9.2.9.", gro
337337
outputs.upToDateWhen { false }
338338
}
339339
}
340+
341+
checkstyle {
342+
toolVersion = libs.versions.checkstyle.get()
343+
configFile = file("${rootProject.projectDir}/config/checkstyle/checkstyle.xml")
344+
configProperties = [
345+
"org.checkstyle.google.suppressionfilter.config": file("${rootProject.projectDir}/config/checkstyle/checkstyle-suppressions.xml"),
346+
]
347+
ignoreFailures = false
348+
maxWarnings = 0
349+
}

config/checkstyle/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Checkstyle for the Embulk project
2+
==================================
3+
4+
* google_check.xml: Downloaded from: https://github.com/checkstyle/checkstyle/blob/checkstyle-9.3/src/main/resources/google_checks.xml
5+
* Commit: 5c1903792f8432243cc8ae5cd79a03a004d3c09c
6+
* checkstyle.xml: Customized from google_check.xml.
7+
* To enable suppressions through checkstyle-suppressions.xml.
8+
* To enable suppressions with @SuppressWarnings.
9+
* To indent with 4-column spaces.
10+
* To limit columns to 180 characters.
11+
* To reject unused imports.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
3+
<!DOCTYPE suppressions PUBLIC
4+
"-//Puppy Crawl//DTD Suppressions 1.2//EN"
5+
"http://checkstyle.sourceforge.net/dtds/suppressions_1_2.dtd">
6+
7+
<suppressions>
8+
<suppress checks="JavadocMethod" files=".*"/>
9+
<suppress checks="JavadocParagraph" files=".*"/>
10+
<suppress checks="JavadocTagContinuationIndentation" files=".*"/>
11+
<suppress checks="MissingJavadocType" files=".*"/>
12+
<suppress checks="SingleLineJavadoc" files=".*"/>
13+
<suppress checks="SummaryJavadoc" files=".*"/>
14+
</suppressions>

config/checkstyle/checkstyle.xml

Lines changed: 368 additions & 0 deletions
Large diffs are not rendered by default.

config/checkstyle/google_checks.xml

Lines changed: 364 additions & 0 deletions
Large diffs are not rendered by default.

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
junit5 = "5.9.2"
44

5+
checkstyle = "9.3"
6+
57
[libraries]
68

79
junit5-bom = { group = "org.junit", name = "junit-bom", version.ref = "junit5" }

src/main/java/org/embulk/util/rubytime/DefaultRubyTimeResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ private OffsetDateTime getOffsetAppliedDateTime(final TemporalAccessor original,
396396
? original.get(ChronoField.MINUTE_OF_HOUR) : this.defaultMinuteOfHour;
397397
int secondOfMinute = original.isSupported(ChronoField.SECOND_OF_MINUTE)
398398
? original.get(ChronoField.SECOND_OF_MINUTE) : this.defaultSecondOfMinute;
399-
int nanoOfSecond = original.isSupported(ChronoField.NANO_OF_SECOND)
399+
final int nanoOfSecond = original.isSupported(ChronoField.NANO_OF_SECOND)
400400
? original.get(ChronoField.NANO_OF_SECOND) : this.defaultNanoOfSecond;
401401

402402
int offset = zoneOffset.getTotalSeconds();

src/main/java/org/embulk/util/rubytime/Format.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ private List<FormatToken> compileInitial() {
145145
* @param beginningIndex index of the character next to {@code '%'} in {@code formatString}.
146146
* @return {@code true} if recognized as a directive, {@code false} otherwise.
147147
*/
148+
@SuppressWarnings("checkstyle:LeftCurly")
148149
private boolean compileDirective(final int beginningIndex) {
149150
final FormatDirectiveOptions.Builder optionsBuilder = FormatDirectiveOptions.builder();
150151

@@ -284,6 +285,8 @@ private boolean compileDirective(final int beginningIndex) {
284285

285286
case '0':
286287
optionsBuilder.setPadding('0');
288+
// fall-through
289+
287290
case '1':
288291
case '2':
289292
case '3':

src/main/java/org/embulk/util/rubytime/FormatDirective.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616

1717
package org.embulk.util.rubytime;
1818

19-
import java.util.ArrayList;
2019
import java.util.Collections;
21-
import java.util.EnumMap;
2220
import java.util.HashMap;
23-
import java.util.List;
2421
import java.util.Map;
2522

2623
/**

src/main/java/org/embulk/util/rubytime/FormatterWithContext.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ String format(final Format format) {
4444
return this.format(format, RubyDateTimeFormatter.ZoneNameStyle.NONE);
4545
}
4646

47+
@SuppressWarnings("checkstyle:LeftCurly")
4748
String format(final Format format, final RubyDateTimeFormatter.ZoneNameStyle zoneNameStyle) {
4849
final StringBuilder builder = new StringBuilder();
4950

@@ -371,6 +372,9 @@ String format(final Format format, final RubyDateTimeFormatter.ZoneNameStyle zon
371372
// %+ is not supported in formatter. %+ is only for parser.
372373
builder.append(token.getImmediate().orElse(""));
373374
break;
375+
376+
default:
377+
// Pass-through.
374378
}
375379
}
376380
}
@@ -616,12 +620,16 @@ private void appendYearWithoutCentury(
616620
* <li>MRI's {@code Time.zone} (the name of the time zone) cannot be set arbitrary.
617621
* It is set almost only from {@code localtime(3)} from the computer's environment,
618622
* such as the TZ environment variable.
619-
* @see <a href="https://twitter.com/shyouhei/status/1245616200874209283">Tweet from @shyouhei (in Japanese)</a>
620-
* @see <a href="https://twitter.com/nalsh/status/1245689453315670022">Tweet from @nalsh (in Japanese)</a>
623+
* <ul>
624+
* <li><a href="https://twitter.com/shyouhei/status/1245616200874209283">Tweet from @shyouhei (in Japanese)</a>
625+
* <li><a href="https://twitter.com/nalsh/status/1245689453315670022">Tweet from @nalsh (in Japanese)</a>
626+
* </ul>
621627
* <li>MRI's {@code Time#strptime} never sets the name of the time zone from its input.
622628
* The name of the time zone is set only from {@code Time.utc} or {@code Time.local}.
623-
* @see <a href="https://docs.ruby-lang.org/en/2.7.0/Time.html#method-c-local">Time.local</a>
624-
* @see <a href="https://docs.ruby-lang.org/en/2.7.0/Time.html#method-c-utc">Time.utc</a>
629+
* <ul>
630+
* <li><a href="https://docs.ruby-lang.org/en/2.7.0/Time.html#method-c-local">Time.local</a>
631+
* <li><a href="https://docs.ruby-lang.org/en/2.7.0/Time.html#method-c-utc">Time.utc</a>
632+
* </ul>
625633
* <li>Embulk uses only {@link java.time.Instant} as its internal timestamp representation.
626634
* </ol>
627635
*
@@ -679,6 +687,7 @@ private void appendYearWithoutCentury(
679687
*
680688
* <p>On the other hand, Embulk's legacy {@code TimestampFormatter} has used {@code org.jruby.util.RubyDateFormat}
681689
* directly. Unlike just {@code Time.strptime}, {@code RubyDateFormat} formats {@code "%Z"} into short names.
690+
*
682691
* @see <a href="https://github.com/jruby/jruby/blob/9.1.15.0/core/src/main/java/org/jruby/util/RubyDateFormat.java#L411-L419">RubyDateFormat#compilePattern</a>
683692
* @see <a href="https://github.com/jruby/jruby/blob/9.1.15.0/core/src/main/java/org/jruby/util/RubyDateFormat.java#L622-L624">RubyDateFormat#format</a>
684693
*
@@ -737,6 +746,8 @@ private void appendTimeZoneName(
737746
builder.append("");
738747
}
739748
break;
749+
default:
750+
// Pass-through.
740751
}
741752
}
742753

@@ -872,6 +883,7 @@ private void appendLongFormatted(
872883
*
873884
* @see <a href="https://github.com/ruby/ruby/blob/v2_6_3/strftime.c#L985-L1092">iso8601wknum</a>
874885
*/
886+
@SuppressWarnings("checkstyle:LeftCurly")
875887
private static int calculateIso8601WeekNumber(final TemporalAccessor temporal) {
876888
final int jan1DayOfWeek = calculateJan1DayOfWeek(temporal);
877889

0 commit comments

Comments
 (0)