Skip to content
This repository was archived by the owner on Mar 15, 2021. It is now read-only.

Commit 5b38426

Browse files
committed
#3 remove unnecessary @throws, rename argument to option
1 parent 19b5ae7 commit 5b38426

File tree

3 files changed

+169
-164
lines changed

3 files changed

+169
-164
lines changed

src/main/java/biz/gabrys/lesscss/compiler2/Less175Compiler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public Less175Compiler() {
9898
* @since 2.0.0
9999
*/
100100
@Override
101-
public String execute(final File source) throws CompilerException {
101+
public String execute(final File source) {
102102
return execute(source, new Less175CompilerOptionsBuilder().create());
103103
}
104104

@@ -141,7 +141,7 @@ public String execute(final File input, final Collection<Object> options) {
141141
}
142142
}
143143

144-
private void initialize() throws InitializationException {
144+
private void initialize() {
145145
InputStream inputStream = null;
146146
InputStreamReader streamReader = null;
147147
try {

src/main/java/biz/gabrys/lesscss/compiler2/Less175CompilerOptionsBuilder.java

Lines changed: 59 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ public Less175CompilerOptionsBuilder withSilent(final boolean silent) {
8181
}
8282

8383
/**
84-
* Returns a command line argument which enables/disables logging compilation warnings.
85-
* @return the command line argument (never {@code null}).
84+
* Returns a command line option which enables/disables logging compilation warnings.
85+
* @return the command line option (never {@code null}).
8686
* @since 2.0.0
8787
* @see #withSilent(boolean)
8888
*/
89-
protected String getSilentCompilerArgument() {
89+
protected String getSilentCompilerOption() {
9090
if (silent) {
9191
return "--silent";
9292
} else {
@@ -108,12 +108,12 @@ public Less175CompilerOptionsBuilder withStrictImports(final boolean strictImpor
108108
}
109109

110110
/**
111-
* Returns a command line argument which enables/disables strict imports.
112-
* @return the command line argument (never {@code null}).
111+
* Returns a command line option which enables/disables strict imports.
112+
* @return the command line option (never {@code null}).
113113
* @since 2.0.0
114114
* @see #withStrictImports(boolean)
115115
*/
116-
protected String getStrictImportsCompilerArgument() {
116+
protected String getStrictImportsCompilerOption() {
117117
if (strictImports) {
118118
return "--strict-imports";
119119
} else {
@@ -133,12 +133,12 @@ public Less175CompilerOptionsBuilder withCompress(final boolean compress) {
133133
}
134134

135135
/**
136-
* Returns a command line argument which enables/disables a CSS code compression.
137-
* @return the command line argument (never {@code null}).
136+
* Returns a command line option which enables/disables a CSS code compression.
137+
* @return the command line option (never {@code null}).
138138
* @since 2.0.0
139139
* @see #withCompress(boolean)
140140
*/
141-
protected String getCompressCompilerArgument() {
141+
protected String getCompressCompilerOption() {
142142
if (compress) {
143143
return "--compress";
144144
} else {
@@ -159,11 +159,11 @@ public Less175CompilerOptionsBuilder withDepends(final boolean depends) {
159159

160160
/**
161161
* TODO what is depends?
162-
* @return command line argument (never {@code null}).
162+
* @return command line option (never {@code null}).
163163
* @since 2.0.0
164164
* @see #withDepends(boolean)
165165
*/
166-
protected String getDependsCompilerArgument() {
166+
protected String getDependsCompilerOption() {
167167
if (depends) {
168168
return "--depends";
169169
} else {
@@ -185,12 +185,12 @@ public Less175CompilerOptionsBuilder withIeCompatability(final boolean ieCompata
185185
}
186186

187187
/**
188-
* Returns a command line argument which enables/disables compatibility with IE browser.
189-
* @return the command line argument (never {@code null}).
188+
* Returns a command line option which enables/disables compatibility with IE browser.
189+
* @return the command line option (never {@code null}).
190190
* @since 2.0.0
191191
* @see #withIeCompatability(boolean)
192192
*/
193-
protected String getIeCompatabilityCompilerArgument() {
193+
protected String getIeCompatabilityCompilerOption() {
194194
if (ieCompatability) {
195195
return "";
196196
} else {
@@ -211,12 +211,12 @@ public Less175CompilerOptionsBuilder withJavaScriptEnabled(final boolean javaScr
211211
}
212212

213213
/**
214-
* Returns a command line argument which allows/disallows usage of JavaScript language.
215-
* @return the command line argument (never {@code null}).
214+
* Returns a command line option which allows/disallows usage of JavaScript language.
215+
* @return the command line option (never {@code null}).
216216
* @since 2.0.0
217217
* @see #withJavaScriptEnabled(boolean)
218218
*/
219-
protected String getJavaScriptEnabledCompilerArgument() {
219+
protected String getJavaScriptEnabledCompilerOption() {
220220
if (javaScriptEnabled) {
221221
return "";
222222
} else {
@@ -243,12 +243,12 @@ public Less175CompilerOptionsBuilder withIncludePaths(final List<String> include
243243
}
244244

245245
/**
246-
* Returns a command line argument representation of the available include paths.
247-
* @return the command line argument (never {@code null}).
246+
* Returns a command line option representation of the available include paths.
247+
* @return the command line option (never {@code null}).
248248
* @since 2.0.0
249249
* @see #withIncludePaths(List)
250250
*/
251-
protected String getIncludePathsCompilerArgument() {
251+
protected String getIncludePathsCompilerOption() {
252252
if (includePaths.isEmpty()) {
253253
return "";
254254
}
@@ -278,12 +278,12 @@ public Less175CompilerOptionsBuilder withLineNumbers(final LineNumbersValue line
278278
}
279279

280280
/**
281-
* Returns a command line argument which enables/disables generating inline source-mapping.
282-
* @return the command line argument (never {@code null}).
281+
* Returns a command line option which enables/disables generating inline source-mapping.
282+
* @return the command line option (never {@code null}).
283283
* @since 2.0.0
284284
* @see #withJavaScriptEnabled(boolean)
285285
*/
286-
protected String getLineNumbersCompilerArgument() {
286+
protected String getLineNumbersCompilerOption() {
287287
if (lineNumbers == LineNumbersValue.DISABLED) {
288288
return "";
289289
} else {
@@ -312,12 +312,12 @@ public Less175CompilerOptionsBuilder withRootPath(final String rootPath) {
312312
}
313313

314314
/**
315-
* Returns a command line argument representation of the root path.
316-
* @return the command line argument (never {@code null}).
315+
* Returns a command line option representation of the root path.
316+
* @return the command line option (never {@code null}).
317317
* @since 2.0.0
318318
* @see #withRootPath(String)
319319
*/
320-
protected String getRootPathCompilerArgument() {
320+
protected String getRootPathCompilerOption() {
321321
if (rootPath != null) {
322322
return "--rootpath=" + rootPath;
323323
} else {
@@ -340,25 +340,28 @@ protected String getRootPathCompilerArgument() {
340340
* background-image: url('images/lamp-post.png');
341341
* }
342342
* </pre>
343-
*
343+
* <p>
344344
* this will output the following normally
345+
* </p>
345346
*
346347
* <pre>
347348
* .icon-1 {
348349
* background-image: url('images/lamp-post.png');
349350
* }
350351
* </pre>
351-
*
352+
* <p>
352353
* but with this option on it will instead output
354+
* </p>
353355
*
354356
* <pre>
355357
* .icon-1 {
356358
* background-image: url('files/images/lamp-post.png');
357359
* }
358360
* </pre>
359-
*
361+
* <p>
360362
* You may also want to consider using the {@code data-uri} function instead of this option, which will embed images
361363
* into the CSS.
364+
* </p>
362365
* @param relativeUrls {@code true} whether the compiler should rewrite relative URLs, otherwise {@code false}.
363366
* @return {@code this} builder.
364367
* @since 2.0.0
@@ -369,12 +372,12 @@ public Less175CompilerOptionsBuilder withRelativeUrls(final boolean relativeUrls
369372
}
370373

371374
/**
372-
* Returns a command line argument which enables/disables rewriting relative URLs.
373-
* @return the command line argument (never {@code null}).
375+
* Returns a command line option which enables/disables rewriting relative URLs.
376+
* @return the command line option (never {@code null}).
374377
* @since 2.0.0
375378
* @see #withRelativeUrls(boolean)
376379
*/
377-
protected String getRelativeUrlsCompilerArgument() {
380+
protected String getRelativeUrlsCompilerOption() {
378381
if (relativeUrls) {
379382
return "--relative-urls";
380383
} else {
@@ -391,8 +394,9 @@ protected String getRelativeUrlsCompilerArgument() {
391394
* height: calc(100% - 10px);
392395
* }
393396
* </pre>
394-
*
397+
* <p>
395398
* will be processed currently.
399+
* </p>
396400
* <p>
397401
* With strict math on, only maths that is inside unnecessary parenthesis will be processed. For instance.
398402
* </p>
@@ -424,12 +428,12 @@ public Less175CompilerOptionsBuilder withStrictMath(final boolean strictMath) {
424428
}
425429

426430
/**
427-
* Returns a command line argument which enables/disables strict math.
428-
* @return the command line argument (never {@code null}).
431+
* Returns a command line option which enables/disables strict math.
432+
* @return the command line option (never {@code null}).
429433
* @since 2.0.0
430434
* @see #withStrictMath(boolean)
431435
*/
432-
protected String getStrictMathCompilerArgument() {
436+
protected String getStrictMathCompilerOption() {
433437
if (strictMath) {
434438
return "--strict-math=on";
435439
} else {
@@ -446,11 +450,12 @@ protected String getStrictMathCompilerArgument() {
446450
* property: 1px * 2px;
447451
* }
448452
* </pre>
449-
*
453+
* <p>
450454
* In this case, things are clearly not right - a length multiplied by a length gives an area, but CSS does not
451455
* support specifying areas. So we assume that the user meant for one of the values to be a value, not a unit of
452456
* length and Less outputs 2px. With strict units on, Less assumes this is a bug in the calculation and throw an
453457
* error.
458+
* </p>
454459
* @param strictUnits {@code true} whether the compiler should guess units in the Less code when it does maths,
455460
* otherwise {@code false}.
456461
* @return {@code this} builder.
@@ -462,12 +467,12 @@ public Less175CompilerOptionsBuilder withStrictUnits(final boolean strictUnits)
462467
}
463468

464469
/**
465-
* Returns a command line argument which enables/disables strict units.
466-
* @return the command line argument (never {@code null}).
470+
* Returns a command line option which enables/disables strict units.
471+
* @return the command line option (never {@code null}).
467472
* @since 2.0.0
468473
* @see #withStrictUnits(boolean)
469474
*/
470-
protected String getStrictUnitsCompilerArgument() {
475+
protected String getStrictUnitsCompilerOption() {
471476
if (strictUnits) {
472477
return "--strict-units=on";
473478
} else {
@@ -481,20 +486,20 @@ protected String getStrictUnitsCompilerArgument() {
481486
* @since 2.0.0
482487
*/
483488
public Collection<Object> create() {
484-
final ListWithoutEmptyValuesBuilder arguments = new ListWithoutEmptyValuesBuilder();
485-
arguments.add(getSilentCompilerArgument());
486-
arguments.add(getStrictImportsCompilerArgument());
487-
arguments.add(getCompressCompilerArgument());
488-
arguments.add(getDependsCompilerArgument());
489-
arguments.add(getIeCompatabilityCompilerArgument());
490-
arguments.add(getJavaScriptEnabledCompilerArgument());
491-
arguments.add(getIncludePathsCompilerArgument());
492-
arguments.add(getLineNumbersCompilerArgument());
493-
arguments.add(getRootPathCompilerArgument());
494-
arguments.add(getRelativeUrlsCompilerArgument());
495-
arguments.add(getStrictMathCompilerArgument());
496-
arguments.add(getStrictUnitsCompilerArgument());
497-
return arguments.create();
489+
final ListWithoutEmptyValuesBuilder options = new ListWithoutEmptyValuesBuilder();
490+
options.add(getSilentCompilerOption());
491+
options.add(getStrictImportsCompilerOption());
492+
options.add(getCompressCompilerOption());
493+
options.add(getDependsCompilerOption());
494+
options.add(getIeCompatabilityCompilerOption());
495+
options.add(getJavaScriptEnabledCompilerOption());
496+
options.add(getIncludePathsCompilerOption());
497+
options.add(getLineNumbersCompilerOption());
498+
options.add(getRootPathCompilerOption());
499+
options.add(getRelativeUrlsCompilerOption());
500+
options.add(getStrictMathCompilerOption());
501+
options.add(getStrictUnitsCompilerOption());
502+
return options.create();
498503
}
499504

500505
/**

0 commit comments

Comments
 (0)