Skip to content

Commit 916b5dc

Browse files
committed
Fix checkstyle violations for Google Java Style
Fix all checkstyle warnings when using google_checks.xml: - NeedBraces: add braces to single-line if/else/for blocks - AvoidStarImport: replace wildcard imports with explicit ones - SummaryJavadoc: add periods to Javadoc summary sentences - MissingJavadocType: add Javadoc to all public types - MissingJavadocMethod: add Javadoc to all public methods - LineLength: wrap lines exceeding 100 characters - OverloadMethodsDeclarationOrder: group overloaded methods - JavadocTagContinuationIndentation: fix tag indentation - AtclauseOrder: reorder @param/@return/@throws tags - VariableDeclarationUsageDistance: move declarations closer to usage - Remove @SuppressFBWarnings annotations (use exclude file instead) - Add checkstyle-suppressions.xml for intentional naming deviations
1 parent 073bb31 commit 916b5dc

40 files changed

Lines changed: 138 additions & 5 deletions

src/main/java/net/bramp/commons/lang3/math/gson/FractionAdapter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class FractionAdapter extends TypeAdapter<Fraction> {
2626
"Immutable") // TODO Remove when https://github.com/google/error-prone/issues/512 is fixed
2727
private final Fraction divideByZero;
2828

29+
/** Constructs a FractionAdapter with default zero values for edge cases. */
2930
public FractionAdapter() {
3031
this(Fraction.ZERO, Fraction.ZERO);
3132
}

src/main/java/net/bramp/ffmpeg/FFmpeg.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,22 @@ public class FFmpeg extends FFcommon {
9595
/** Supported channel layouts. */
9696
private List<ChannelLayout> channelLayouts = null;
9797

98+
/** Constructs an FFmpeg instance using the default path. */
9899
public FFmpeg() throws IOException {
99100
this(DEFAULT_PATH, new RunProcessFunction());
100101
}
101102

103+
/** Constructs an FFmpeg instance using the default path and the specified process function. */
102104
public FFmpeg(@Nonnull ProcessFunction runFunction) throws IOException {
103105
this(DEFAULT_PATH, runFunction);
104106
}
105107

108+
/** Constructs an FFmpeg instance using the specified path. */
106109
public FFmpeg(@Nonnull String path) throws IOException {
107110
this(path, new RunProcessFunction());
108111
}
109112

113+
/** Constructs an FFmpeg instance using the specified path and process function. */
110114
@SuppressWarnings("this-escape")
111115
public FFmpeg(@Nonnull String path, @Nonnull ProcessFunction runFunction) throws IOException {
112116
super(path, runFunction);
@@ -287,6 +291,7 @@ public synchronized List<ChannelLayout> channelLayouts() throws IOException {
287291
return this.channelLayouts;
288292
}
289293

294+
/** Creates a progress parser for the given listener. */
290295
protected ProgressParser createProgressParser(ProgressListener listener) throws IOException {
291296
// TODO In future create the best kind for this OS, unix socket, named pipe, or TCP.
292297
try {
@@ -331,6 +336,7 @@ public void run(FFmpegBuilder builder, @Nullable ProgressListener listener) thro
331336
}
332337
}
333338

339+
/** Returns a new FFmpegBuilder instance. */
334340
@CheckReturnValue
335341
public FFmpegBuilder builder() {
336342
return new FFmpegBuilder();

src/main/java/net/bramp/ffmpeg/FFmpegException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class FFmpegException extends IOException {
99
private static final long serialVersionUID = 3048288225568984942L;
1010
private final FFmpegError error;
1111

12+
/** Constructs an FFmpegException with the specified message and error details. */
1213
public FFmpegException(String message, FFmpegError error) {
1314
super(message);
1415
this.error = error;

src/main/java/net/bramp/ffmpeg/FFmpegExecutor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,28 @@ public class FFmpegExecutor {
1515
final FFmpeg ffmpeg;
1616
final FFprobe ffprobe;
1717

18+
/** Constructs an FFmpegExecutor using default FFmpeg and FFprobe instances. */
1819
public FFmpegExecutor() throws IOException {
1920
this(new FFmpeg(), new FFprobe());
2021
}
2122

23+
/** Constructs an FFmpegExecutor with the specified FFmpeg instance. */
2224
public FFmpegExecutor(FFmpeg ffmpeg) throws IOException {
2325
this(ffmpeg, new FFprobe());
2426
}
2527

28+
/** Constructs an FFmpegExecutor with the specified FFmpeg and FFprobe instances. */
2629
public FFmpegExecutor(FFmpeg ffmpeg, FFprobe ffprobe) {
2730
this.ffmpeg = checkNotNull(ffmpeg);
2831
this.ffprobe = checkNotNull(ffprobe);
2932
}
3033

34+
/** Creates a single-pass FFmpeg job from the given builder. */
3135
public FFmpegJob createJob(FFmpegBuilder builder) {
3236
return new SinglePassFFmpegJob(ffmpeg, builder);
3337
}
3438

39+
/** Creates a single-pass FFmpeg job with a progress listener. */
3540
public FFmpegJob createJob(FFmpegBuilder builder, ProgressListener listener) {
3641
return new SinglePassFFmpegJob(ffmpeg, builder, listener);
3742
}
@@ -47,6 +52,7 @@ public FFmpegJob createTwoPassJob(FFmpegBuilder builder) {
4752
return new TwoPassFFmpegJob(ffmpeg, builder);
4853
}
4954

55+
/** Creates a two-pass FFmpeg job with a progress listener. */
5056
public FFmpegJob createTwoPassJob(FFmpegBuilder builder, ProgressListener listener) {
5157
return new TwoPassFFmpegJob(ffmpeg, builder, listener);
5258
}

src/main/java/net/bramp/ffmpeg/FFprobe.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,43 @@ public class FFprobe extends FFcommon {
3030

3131
static final Gson gson = FFmpegUtils.getGson();
3232

33+
/** Constructs an FFprobe instance using the default path. */
3334
public FFprobe() throws IOException {
3435
this(DEFAULT_PATH, new RunProcessFunction());
3536
}
3637

38+
/** Constructs an FFprobe instance using the default path and the specified process function. */
3739
public FFprobe(@Nonnull ProcessFunction runFunction) throws IOException {
3840
this(DEFAULT_PATH, runFunction);
3941
}
4042

43+
/** Constructs an FFprobe instance using the specified path. */
4144
public FFprobe(@Nonnull String path) throws IOException {
4245
this(path, new RunProcessFunction());
4346
}
4447

48+
/** Constructs an FFprobe instance using the specified path and process function. */
4549
public FFprobe(@Nonnull String path, @Nonnull ProcessFunction runFunction) {
4650
super(path, runFunction);
4751
}
4852

53+
/** Probes the specified media file and returns the result. */
4954
public FFmpegProbeResult probe(String mediaPath) throws IOException {
5055
return probe(mediaPath, null);
5156
}
5257

58+
/** Probes the specified media file with an optional user agent. */
5359
public FFmpegProbeResult probe(String mediaPath, @Nullable String userAgent) throws IOException {
5460
return probe(this.builder().setInput(mediaPath).setUserAgent(userAgent));
5561
}
5662

63+
/** Probes media using the supplied FFprobeBuilder. */
5764
public FFmpegProbeResult probe(FFprobeBuilder builder) throws IOException {
5865
checkNotNull(builder);
5966
return probe(builder.build());
6067
}
6168

69+
/** Probes media with an optional user agent and extra arguments. */
6270
public FFmpegProbeResult probe(
6371
String mediaPath, @Nullable String userAgent, @Nullable String... extraArgs)
6472
throws IOException {
@@ -123,6 +131,7 @@ public void run(List<String> args) throws IOException {
123131
super.run(args);
124132
}
125133

134+
/** Returns a new FFprobeBuilder instance. */
126135
@CheckReturnValue
127136
public FFprobeBuilder builder() {
128137
return new FFprobeBuilder();

src/main/java/net/bramp/ffmpeg/ProcessFunction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
* @author bramp
1010
*/
1111
public interface ProcessFunction {
12+
/** Runs a process with the given arguments and returns the process handle. */
1213
Process run(List<String> args) throws IOException;
1314
}

src/main/java/net/bramp/ffmpeg/RunProcessFunction.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ public Process run(List<String> args) throws IOException {
3737
return builder.start();
3838
}
3939

40+
/** Sets the working directory for the process using a path string. */
4041
public RunProcessFunction setWorkingDirectory(String workingDirectory) {
4142
this.workingDirectory = new File(workingDirectory);
4243
return this;
4344
}
4445

46+
/** Sets the working directory for the process using a File object. */
4547
public RunProcessFunction setWorkingDirectory(File workingDirectory) {
4648
this.workingDirectory = workingDirectory;
4749
return this;

src/main/java/net/bramp/ffmpeg/builder/AbstractFFmpegInputBuilder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@ public abstract class AbstractFFmpegInputBuilder<T extends AbstractFFmpegInputBu
1818
*/
1919
private int streamLoop;
2020

21+
/** Constructs an input builder with the given parent and filename. */
2122
protected AbstractFFmpegInputBuilder(FFmpegBuilder parent, String filename) {
2223
this(parent, null, filename);
2324
}
2425

26+
/** Constructs an input builder with the given parent, probe result, and filename. */
2527
protected AbstractFFmpegInputBuilder(
2628
FFmpegBuilder parent, FFmpegProbeResult probeResult, String filename) {
2729
super(parent, filename);
2830
this.probeResult = probeResult;
2931
}
3032

33+
/** Enables reading input at native frame rate. */
3134
public T readAtNativeFrameRate() {
3235
this.readAtNativeFrameRate = true;
3336
return getThis();

src/main/java/net/bramp/ffmpeg/builder/AbstractFFmpegOutputBuilder.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,17 @@ public abstract class AbstractFFmpegOutputBuilder<T extends AbstractFFmpegOutput
110110

111111
protected String complexFilter;
112112

113+
/** Constructs a default output builder. */
113114
public AbstractFFmpegOutputBuilder() {
114115
super();
115116
}
116117

118+
/** Constructs an output builder with the given parent and filename. */
117119
protected AbstractFFmpegOutputBuilder(FFmpegBuilder parent, String filename) {
118120
super(parent, filename);
119121
}
120122

123+
/** Constructs an output builder with the given parent and URI. */
121124
protected AbstractFFmpegOutputBuilder(FFmpegBuilder parent, URI uri) {
122125
super(parent, uri);
123126
}
@@ -145,6 +148,7 @@ public T setVideoQuality(double quality) {
145148
return (T) this;
146149
}
147150

151+
/** Sets the video bit stream filter. */
148152
public T setVideoBitStreamFilter(String filter) {
149153
this.video_bit_stream_filter = checkNotEmpty(filter, "filter must not be empty");
150154
return (T) this;

src/main/java/net/bramp/ffmpeg/builder/AbstractFFmpegStreamBuilder.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,52 +106,63 @@ public abstract class AbstractFFmpegStreamBuilder<T extends AbstractFFmpegStream
106106

107107
public boolean throwWarnings = true; // TODO Either delete this, or apply it consistently
108108

109+
/** Constructs a stream builder with no parent. */
109110
protected AbstractFFmpegStreamBuilder() {
110111
this.parent = null;
111112
}
112113

114+
/** Constructs a stream builder with the given parent and output filename. */
113115
protected AbstractFFmpegStreamBuilder(FFmpegBuilder parent, String filename) {
114116
this.parent = checkNotNull(parent);
115117
this.filename = checkNotEmpty(filename, "filename must not be empty");
116118
}
117119

120+
/** Constructs a stream builder with the given parent and output URI. */
118121
protected AbstractFFmpegStreamBuilder(FFmpegBuilder parent, URI uri) {
119122
this.parent = checkNotNull(parent);
120123
this.uri = checkValidStream(uri);
121124
}
122125

126+
/** Returns this instance for fluent API chaining. */
123127
protected abstract T getThis();
124128

129+
/** Applies the given encoding options to this builder. */
125130
public T useOptions(EncodingOptions opts) {
126131
Mapper.map(opts, this);
127132
return getThis();
128133
}
129134

135+
/** Applies the given main encoding options to this builder. */
130136
public T useOptions(MainEncodingOptions opts) {
131137
Mapper.map(opts, this);
132138
return getThis();
133139
}
134140

141+
/** Applies the given audio encoding options to this builder. */
135142
public T useOptions(AudioEncodingOptions opts) {
136143
Mapper.map(opts, this);
137144
return getThis();
138145
}
139146

147+
/** Applies the given video encoding options to this builder. */
140148
public T useOptions(VideoEncodingOptions opts) {
141149
Mapper.map(opts, this);
142150
return getThis();
143151
}
144152

153+
/** Disables video output. */
145154
public T disableVideo() {
146155
this.video_enabled = false;
147156
return getThis();
148157
}
149158

159+
/** Disables audio output. */
150160
public T disableAudio() {
151161
this.audio_enabled = false;
152162
return getThis();
153163
}
154164

165+
/** Disables subtitle output. */
155166
public T disableSubtitle() {
156167
this.subtitle_enabled = false;
157168
return getThis();
@@ -207,6 +218,7 @@ public T setPreset(String preset) {
207218
return getThis();
208219
}
209220

221+
/** Sets the output filename. */
210222
public T setFilename(String filename) {
211223
this.filename = checkNotEmpty(filename, "filename must not be empty");
212224
return getThis();
@@ -232,10 +244,12 @@ public T setFilename(Path path) {
232244
return setFilename(checkNotNull(path).toString());
233245
}
234246

247+
/** Returns the output filename. */
235248
public String getFilename() {
236249
return filename;
237250
}
238251

252+
/** Sets the output URI. */
239253
public T setUri(URI uri) {
240254
this.uri = checkValidStream(uri);
241255
return getThis();
@@ -317,6 +331,7 @@ public T setFrames(int frames) {
317331
return getThis();
318332
}
319333

334+
/** Checks if the given width or height value is valid. */
320335
protected static boolean isValidSize(int widthOrHeight) {
321336
return widthOrHeight > 0 || widthOrHeight == -1;
322337
}
@@ -527,6 +542,7 @@ public T setDuration(long duration, TimeUnit units) {
527542
return getThis();
528543
}
529544

545+
/** Sets the strict mode for standards compliance. */
530546
public T setStrict(Strict strict) {
531547
this.strict = checkNotNull(strict);
532548
return getThis();
@@ -607,6 +623,7 @@ public FFmpegBuilder done() {
607623
*/
608624
public abstract EncodingOptions buildOptions();
609625

626+
/** Builds the command-line arguments for the given pass using the parent builder. */
610627
protected List<String> build(int pass) {
611628
Preconditions.checkState(parent != null, "Can not build without parent being set");
612629
return build(parent, pass);
@@ -659,8 +676,10 @@ protected List<String> build(FFmpegBuilder parent, int pass) {
659676
return args.build();
660677
}
661678

679+
/** Adds source and target specific arguments for the given pass. */
662680
protected abstract void addSourceTarget(int pass, ImmutableList.Builder<String> args);
663681

682+
/** Adds global flags such as format, preset, and time options to the arguments. */
664683
protected void addGlobalFlags(FFmpegBuilder parent, ImmutableList.Builder<String> args) {
665684
if (strict != Strict.NORMAL) {
666685
args.add("-strict", strict.toString());
@@ -689,6 +708,7 @@ protected void addGlobalFlags(FFmpegBuilder parent, ImmutableList.Builder<String
689708
args.addAll(meta_tags);
690709
}
691710

711+
/** Adds audio-related flags such as codec, channels, and sample rate to the arguments. */
692712
protected void addAudioFlags(ImmutableList.Builder<String> args) {
693713
if (!Strings.isNullOrEmpty(audio_codec)) {
694714
args.add("-acodec", audio_codec);
@@ -707,6 +727,7 @@ protected void addAudioFlags(ImmutableList.Builder<String> args) {
707727
}
708728
}
709729

730+
/** Adds video-related flags such as codec, frame rate, and resolution to the arguments. */
710731
protected void addVideoFlags(FFmpegBuilder parent, ImmutableList.Builder<String> args) {
711732
if (video_frames != null) {
712733
args.add("-vframes", video_frames.toString());
@@ -745,6 +766,7 @@ protected void addVideoFlags(FFmpegBuilder parent, ImmutableList.Builder<String>
745766
}
746767
}
747768

769+
/** Adds format-related arguments such as stream mappings. */
748770
protected void addFormatArgs(ImmutableList.Builder<String> args) {
749771
for (String map : maps) {
750772
args.add("-map", map);

0 commit comments

Comments
 (0)