Skip to content

Commit 3e56661

Browse files
committed
Code clean up
1 parent 501554d commit 3e56661

File tree

7 files changed

+43
-48
lines changed

7 files changed

+43
-48
lines changed

src/main/java/org/utplsql/maven/plugin/CustomTypeMapping.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/**
44
* Bean used by Maven to populate its model.
5+
*
56
* {@code
67
* <customTypeMapping>
78
* <type>...</type>

src/main/java/org/utplsql/maven/plugin/UtPLSQLMojo.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.utplsql.api.reporter.Reporter;
2525
import org.utplsql.api.reporter.ReporterFactory;
2626
import org.utplsql.maven.plugin.helper.PluginDefault;
27-
import org.utplsql.maven.plugin.helper.SQLScannerHelper;
27+
import org.utplsql.maven.plugin.helper.SqlScannerHelper;
2828
import org.utplsql.maven.plugin.model.ReporterParameter;
2929
import org.utplsql.maven.plugin.reporter.ReporterWriter;
3030

@@ -72,7 +72,10 @@ public class UtPLSQLMojo extends AbstractMojo {
7272
@Parameter
7373
protected final List<String> paths = new ArrayList<>();
7474

75-
// Sources Configuration
75+
/**
76+
* Sources Configuration
77+
*/
78+
7679
@Parameter
7780
protected final List<Resource> sources = new ArrayList<>();
7881

@@ -94,7 +97,9 @@ public class UtPLSQLMojo extends AbstractMojo {
9497
@Parameter
9598
private List<CustomTypeMapping> sourcesCustomTypeMapping;
9699

97-
// Tests Configuration
100+
/**
101+
* Tests Configuration
102+
*/
98103
@Parameter
99104
protected final List<Resource> tests = new ArrayList<>();
100105

@@ -137,7 +142,9 @@ public class UtPLSQLMojo extends AbstractMojo {
137142
@Parameter
138143
protected boolean dbmsOutput;
139144

140-
// Color in the console, bases on Maven logging configuration.
145+
/**
146+
* Color in the console, bases on Maven logging configuration.
147+
*/
141148
private final boolean colorConsole = MessageUtils.isColorEnabled();
142149

143150
private ReporterWriter reporterWriter;
@@ -242,9 +249,10 @@ private FileMapperOptions buildSourcesOptions() throws MojoExecutionException {
242249
}
243250
}
244251

245-
List<String> scripts = SQLScannerHelper.findSQLs(project.getBasedir(), sources,
252+
List<String> scripts = SqlScannerHelper.findSqlScripts(project.getBasedir(), sources,
246253
PluginDefault.SOURCE_DIRECTORY, PluginDefault.SOURCE_FILE_PATTERN);
247-
return createFileMapperOptions(scripts, sourcesOwner, sourcesRegexExpression, sourcesOwnerSubexpression, sourcesNameSubexpression, sourcesTypeSubexpression, sourcesCustomTypeMapping);
254+
return createFileMapperOptions(scripts, sourcesOwner, sourcesRegexExpression, sourcesOwnerSubexpression,
255+
sourcesNameSubexpression, sourcesTypeSubexpression, sourcesCustomTypeMapping);
248256

249257
} catch (Exception e) {
250258
throw new MojoExecutionException("Invalid <SOURCES> in your pom.xml", e);
@@ -263,7 +271,7 @@ private FileMapperOptions buildTestsOptions() throws MojoExecutionException {
263271
}
264272
}
265273

266-
List<String> scripts = SQLScannerHelper.findSQLs(project.getBasedir(), tests, PluginDefault.TEST_DIRECTORY,
274+
List<String> scripts = SqlScannerHelper.findSqlScripts(project.getBasedir(), tests, PluginDefault.TEST_DIRECTORY,
267275
PluginDefault.TEST_FILE_PATTERN);
268276
return createFileMapperOptions(scripts, testsOwner, testsRegexExpression, testsOwnerSubexpression,
269277
testsNameSubexpression, testsTypeSubexpression, testsCustomTypeMapping);
@@ -342,8 +350,7 @@ private List<Reporter> initReporters(Connection connection, Version utlVersion,
342350
return reporterList;
343351
}
344352

345-
private void logParameters(FileMapperOptions sourceMappingOptions, FileMapperOptions testMappingOptions,
346-
List<Reporter> reporterList) {
353+
private void logParameters(FileMapperOptions sourceMappingOptions, FileMapperOptions testMappingOptions, List<Reporter> reporterList) {
347354
Log log = getLog();
348355
log.info("Invoking TestRunner with: " + targetDir);
349356

src/main/java/org/utplsql/maven/plugin/helper/PluginDefault.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
import java.util.Collections;
66

77
/**
8-
* This class provides methods to retrieve the list of resources in the default
9-
* {@literal <source> and <test>} directories.
10-
*
8+
* This class provides methods to retrieve the list of resources in the default {@literal <source> and <test>} directories.
9+
*
1110
* @author Alberto Hernández
1211
*/
1312
public class PluginDefault {
@@ -37,7 +36,7 @@ private PluginDefault() {
3736

3837
/**
3938
* This method returns {@link Resource} for the default {@code source} directory
40-
*
39+
*
4140
* @return a {@link Resource}
4241
*/
4342
public static Resource buildDefaultSource() {
@@ -46,7 +45,7 @@ public static Resource buildDefaultSource() {
4645

4746
/**
4847
* This method returns {@link Resource} for the default {@code test} directory
49-
*
48+
*
5049
* @return a {@link Resource}
5150
*/
5251
public static Resource buildDefaultTest() {

src/main/java/org/utplsql/maven/plugin/helper/ReporterDefault.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
/**
66
* This class is an enumeration of all the known reporter in {@code utPLSQL}.
77
* Furthermore, it defines the default output file for each {@link Reporter}.
8-
* In case the output file is set to {@code -}, it will mean the stdout of the
9-
* process.
8+
* In case the output file is set to {@code -}, it will mean the stdout of the process.
109
*
1110
* @author Alberto Hernández
1211
*/

src/main/java/org/utplsql/maven/plugin/helper/SQLScannerHelper.java renamed to src/main/java/org/utplsql/maven/plugin/helper/SqlScannerHelper.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
*
1616
* @author Alberto Hernández
1717
*/
18-
public class SQLScannerHelper {
18+
public class SqlScannerHelper {
1919

20-
private SQLScannerHelper() {
21-
// NA
20+
private SqlScannerHelper() {
2221
}
2322

2423
/**
@@ -30,7 +29,7 @@ private SQLScannerHelper() {
3029
* @param defaultFilePattern the default file pattern
3130
* @return a list of the files found
3231
*/
33-
public static List<String> findSQLs(File baseDir, List<Resource> resources, String defaultDirectory, String defaultFilePattern) {
32+
public static List<String> findSqlScripts(File baseDir, List<Resource> resources, String defaultDirectory, String defaultFilePattern) {
3433
List<String> founds = new ArrayList<>();
3534

3635
for (Resource resource : resources) {
@@ -61,8 +60,7 @@ private static DirectoryScanner buildScanner(String baseDir, Resource resource)
6160
if (resource != null) {
6261
File fileBaseDir = new File(baseDir, resource.getDirectory());
6362
if (!fileBaseDir.exists() || !fileBaseDir.isDirectory() || !fileBaseDir.canRead()) {
64-
throw new IllegalArgumentException(
65-
format("Invalid <directory> %s in resource. Check your pom.xml", resource.getDirectory()));
63+
throw new IllegalArgumentException(format("Invalid <directory> %s in resource. Check your pom.xml", resource.getDirectory()));
6664
}
6765

6866
DirectoryScanner scanner = new DirectoryScanner();

src/main/java/org/utplsql/maven/plugin/model/ReporterParameter.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
/**
66
* Represents a reporter parameter in the pom file.
7+
*
78
* {@code
89
* <reporter>
910
* <name>...</name>
1011
* <fileOutput>...</fileOutput>
1112
* <consoleOutput>...</consoleOutput>
1213
* </reporter>
1314
* }
14-
*
15+
*
1516
* @author Alberto Hernández
1617
*/
1718
public class ReporterParameter {
@@ -20,16 +21,9 @@ public class ReporterParameter {
2021
private String fileOutput;
2122
private Boolean consoleOutput;
2223

23-
/**
24-
* Creates a new reporter parameter.
25-
*/
26-
public ReporterParameter() {
27-
super();
28-
}
29-
3024
/**
3125
* Returns the reporter name.
32-
*
26+
*
3327
* @return the reporter name
3428
*/
3529
public String getName() {
@@ -38,7 +32,7 @@ public String getName() {
3832

3933
/**
4034
* Sets the reporter name.
41-
*
35+
*
4236
* @param name the reporter name
4337
*/
4438
public void setName(String name) {
@@ -47,7 +41,7 @@ public void setName(String name) {
4741

4842
/**
4943
* Returns reporter output file.
50-
*
44+
*
5145
* @return the output file name
5246
*/
5347
public String getFileOutput() {
@@ -56,7 +50,7 @@ public String getFileOutput() {
5650

5751
/**
5852
* Returns whether the file output is enabled or not.
59-
*
53+
*
6054
* @return true if the file output is enabled, false otherwise
6155
*/
6256
public boolean isFileOutput() {
@@ -65,7 +59,7 @@ public boolean isFileOutput() {
6559

6660
/**
6761
* Sets the output file.
68-
*
62+
*
6963
* @param fileOutput the output file name
7064
*/
7165
public void setFileOutput(String fileOutput) {
@@ -74,7 +68,7 @@ public void setFileOutput(String fileOutput) {
7468

7569
/**
7670
* Returns the console output option.
77-
*
71+
*
7872
* @return the console output option
7973
*/
8074
public Boolean getConsoleOutput() {
@@ -83,7 +77,7 @@ public Boolean getConsoleOutput() {
8377

8478
/**
8579
* Returns whether the console output should be enabled or not.
86-
*
80+
*
8781
* @return true if console output is enable, false otherwise
8882
*/
8983
public Boolean isConsoleOutput() {
@@ -92,7 +86,7 @@ public Boolean isConsoleOutput() {
9286

9387
/**
9488
* Sets the console output option.
95-
*
89+
*
9690
* @param consoleOutput the console output option
9791
*/
9892
public void setConsoleOutput(boolean consoleOutput) {

src/main/java/org/utplsql/maven/plugin/reporter/ReporterWriter.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,11 @@ public void writeReporters(Connection connection) throws MojoExecutionException
6565
}
6666
}
6767

68-
private void writeReports(Connection connection, Reporter reporter, ReporterParameter reporterParameter)
69-
throws MojoExecutionException {
70-
List<PrintStream> printStreams = new ArrayList<>();
71-
FileOutputStream fout = null;
72-
73-
//
68+
private void writeReports(Connection connection, Reporter reporter, ReporterParameter reporterParameter) throws MojoExecutionException {
69+
FileOutputStream fileOutputStream = null;
7470
try {
7571
OutputBuffer buffer = OutputBufferProvider.getCompatibleOutputBuffer(databaseVersion, reporter, connection);
72+
List<PrintStream> printStreams = new ArrayList<>();
7673

7774
if (reporterParameter.isFileOutput()) {
7875

@@ -86,11 +83,11 @@ private void writeReports(Connection connection, Reporter reporter, ReporterPara
8683
file.getParentFile().mkdirs();
8784
}
8885

89-
fout = new FileOutputStream(file);
86+
fileOutputStream = new FileOutputStream(file);
9087
log.info(format("Writing report %s to %s", reporter.getTypeName(), file.getAbsolutePath()));
9188

9289
// Added to the Report
93-
printStreams.add(new PrintStream(fout));
90+
printStreams.add(new PrintStream(fileOutputStream));
9491
}
9592

9693
if (reporterParameter.isConsoleOutput()) {
@@ -101,9 +98,9 @@ private void writeReports(Connection connection, Reporter reporter, ReporterPara
10198
} catch (Exception e) {
10299
throw new MojoExecutionException("Unexpected error opening file ouput ", e);
103100
} finally {
104-
if (fout != null) {
101+
if (fileOutputStream != null) {
105102
try {
106-
fout.close();
103+
fileOutputStream.close();
107104
} catch (IOException e) {
108105
log.info(format("Failed to closing the reporting %s", reporterParameter.getClass()));
109106
}

0 commit comments

Comments
 (0)