Skip to content

Commit

Permalink
Build - clean warnings and errors (#267)
Browse files Browse the repository at this point in the history
* fix(cukedoctor-converter): cukedoctor-maven-plugin is latest release version

* fix(cukedoctor-maven-plugin): update dependencies version

* fix(cukedoctor-converter): Document attributes are scanning fields injected by instrumentation such as jacoco

* fix(deps): remove duplicate dependencies from main and spi-example

* fix(maven-plugin): update @component to @parameter

* fix(javadoc): add missing annotations

* chore: remove useless cucumber cache

* fix(main,tests): clean files/directories after generating them in root directory

* build: pull up dependencies and plugins versions

* fix(logging): show hidden logs by the nop SLF4J

* refactor(logging): switch to SLF4J to benefit from perfs

* fix(coverage): add a version to jaxb dependency

* fix(logging): log fields should be private
  • Loading branch information
rdlopes authored Jul 31, 2022
1 parent 5ac98ff commit 8a5cf9c
Show file tree
Hide file tree
Showing 37 changed files with 538 additions and 434 deletions.
66 changes: 10 additions & 56 deletions cukedoctor-converter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,18 @@
<dependency>
<groupId>com.github.cukedoctor</groupId>
<artifactId>cukedoctor-extension</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>io.github.robwin</groupId>
<artifactId>markup-document-builder</artifactId>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.11.3</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.11.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
Expand All @@ -83,10 +62,18 @@
<id>perf</id>

<dependencies>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
<build>
Expand All @@ -101,20 +88,9 @@
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<executable>java</executable>
<arguments>
Expand All @@ -132,19 +108,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>add-source</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<sources>
<source>src/perf/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand All @@ -158,7 +121,6 @@
<plugin>
<groupId>com.github.cukedoctor</groupId>
<artifactId>cukedoctor-maven-plugin</artifactId>
<version>${project.parent.version}</version>
<configuration>
<outputFileName>cukedoctor-documentation</outputFileName>
<documentTitle>Cukedoctor Documentation</documentTitle>
Expand All @@ -174,24 +136,16 @@
<docVersion>${project.parent.version}</docVersion>
<allowUriRead>true</allowUriRead>
</configuration>
<executions>
<execution>
<goals>
<goal>execute</goal>
</goals>
<phase>install</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-publish-plugin</artifactId>
<version>1.1</version>
<configuration>
<checkoutDirectory>${project.build.outputDirectory}</checkoutDirectory>
<checkinComment>Publishing Cukedoctor-${project.parent.version} living documentation.</checkinComment>
<content>target/cukedoctor</content>
<skipDeletedFiles>true</skipDeletedFiles>
<!--suppress MavenModelInspection -->
<pubScmUrl>scm:git:https://${GH_TOKEN}@github.com/rmpestano/cukedoctor.git</pubScmUrl>
<scmBranch>gh-pages</scmBranch>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,24 @@ public interface CukedoctorConverter {
String getDocumentationTitle();

/**
* @param features the features to render
* @return underlying Converter instance
* @deprecated Use an appropriate instance of FeatureRenderer to render the document features only
* e.g. CukedoctorFeatureRenderer
*/
@Deprecated
CukedoctorConverter renderFeatures(List<Feature> features);

/**
* @return underlying Converter instance
* @deprecated Use an appropriate instance of FeatureRenderer to render the document features only
* e.g. CukedoctorFeatureRenderer
*/
@Deprecated
CukedoctorConverter renderFeatures();

/**
* @return underlying Converter instance
* @deprecated Use an appropriate instance of HeaderRenderer to render the document attributes
* only e.g. CukedoctorHeaderRenderer
*/
Expand All @@ -41,8 +45,7 @@ public interface CukedoctorConverter {
/**
* @deprecated Use an appropriate instance of SummaryRenderer to render the document summary only
* e.g. CukedoctorSummaryRenderer
* @return document overall summary which gathers information about all features like number of
* steps, execution time, total passed scenarios and so on
* @return underlying Converter instance
*/
@Deprecated
CukedoctorConverter renderSummary();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

import com.github.cukedoctor.util.Constants;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** Created by pestano on 04/06/15. Document overall configuration */
public class DocumentAttributes {

private static final Logger log = LoggerFactory.getLogger(DocumentAttributes.class);

private String docTitle = "Living Documentation";
private String backend = "html5";
private String docType = "book";
Expand Down Expand Up @@ -303,18 +307,19 @@ public Map<String, Object> toMap() {

private Map<String, Object> createAttributesMap() {
Map<String, Object> attributesMap = new HashMap<>();
// fields can be added by instrumenting java class (e.g. jacoco or logger)
List<String> ignoredFieldNames = Arrays.asList("$jacocodata", "log");
for (Field field : getClass().getDeclaredFields()) {
try {
String fieldName = field.getName();
Object fieldValue = getFieldValue(this, fieldName);
if (fieldValue != null) {
if (fieldValue != null && !ignoredFieldNames.contains(fieldName.toLowerCase())) {
Constants.Attributes.Name asciidocAttrName =
Constants.Attributes.Name.valueOf(fieldName.toUpperCase());
attributesMap.put(asciidocAttrName.getName(), fieldValue.toString());
}
} catch (Exception e) {
Logger.getLogger(getClass().getName())
.log(Level.WARNING, "Could not get field value of attribute: " + field.getName(), e);
log.warn("Could not get field value of attribute: {}", field.getName(), e);
}
}
return attributesMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRawValue;
import java.util.List;
import java.util.logging.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@JsonIgnoreProperties(ignoreUnknown = true)
public class Step {

private static final Logger log = LoggerFactory.getLogger(Step.class);

private String name;
private String keyword;
private String line;
Expand Down Expand Up @@ -116,8 +119,7 @@ public Long getDuration() {

public Status getStatus() {
if (result == null || result.getStatus() == null) {
Logger.getLogger(getClass().getName())
.warning("Line " + line + " : " + "Step is missing Result: " + keyword + " : " + name);
log.warn("Line {}: Step is missing Result: {}:{}", line, keyword, name);
return Status.missing;
} else {
return result.getStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ public Boolean isDisableMinMaxExtension() {

/**
* Path to be used as relative when looking for introChapterAdoc see {@link
* CukedoctorConverterImpl#renderIntro()}.
*
* <p>used by com.github.cukedoctor.util.{@link
* CukedoctorConverterImpl#renderIntro()}. used by com.github.cukedoctor.util.{@link
* com.github.cukedoctor.util.FileUtil#findFiles(String, String, boolean, String)}
*
* @return the relative path to the intro chapter
*/
public String getIntroChapterRelativePath() {
return introChapterRelativePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import java.io.*;
import java.text.MessageFormat;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* This class is responsible for internationalization.
Expand All @@ -20,7 +20,7 @@
public class I18nLoader extends ResourceBundle.Control {

private static I18nLoader instance;
private static Logger log = Logger.getLogger(I18nLoader.class.getName());
private static final Logger log = LoggerFactory.getLogger(I18nLoader.class);

private ResourceBundle bundle;

Expand Down Expand Up @@ -66,10 +66,9 @@ private void init(List<Feature> features) {
try {
bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
} catch (Exception e) {
log.warning(
String.format(
"No resource bundle found for language %s. Using 'cukedoctor_en.properties' as default bundle.",
lang));
log.warn(
"No resource bundle found for language {}. Using 'cukedoctor_en.properties' as default bundle.",
lang);
try {
bundle =
new PropertyResourceBundle(
Expand Down Expand Up @@ -99,12 +98,12 @@ private InputStream findCukedoctorProperties(String baseDir) {
List<String> files = FileUtil.findFiles(baseDir, "cukedoctor.properties", true);
if (files != null && !files.isEmpty()) {
String path = files.get(0);
log.fine("Loading cukedoctor resource bundle from: " + path);
log.trace("Loading cukedoctor resource bundle from: {}", path);
File file = new File(path);
try {
return new FileInputStream(file);
} catch (Exception e) {
log.log(Level.WARNING, "Could not load resource bundle from target folder", e);
log.warn("Could not load resource bundle from target folder", e);
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import com.github.cukedoctor.util.FileUtil;
import java.io.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** Created by pestano on 04/06/15. */
public class FeatureParser {
static final Logger log = Logger.getLogger(FeatureParser.class.getName());
private static final Logger log = LoggerFactory.getLogger(FeatureParser.class);

/**
* @param json absolute path to cucumber json output file
Expand All @@ -27,8 +27,7 @@ public static List<Feature> parse(String json) {
while (it.hasNext()) {
Feature feature = it.next();
if (!feature.isCucumberFeature()) {
log.warning(
"json:" + json + " is NOT a Cucumber feature result file and will be ignored");
log.warn("json: {} is NOT a Cucumber feature result file and will be ignored", json);
it.remove();
} else {
feature.initScenarios();
Expand All @@ -37,13 +36,13 @@ public static List<Feature> parse(String json) {
}

} catch (FileNotFoundException e) {
log.log(Level.WARNING, "Could not find json file:" + json);
log.warn("Could not find json file: {}", json);
} catch (JsonMappingException e) {
log.log(Level.WARNING, "Could not map json file:" + json);
log.warn("Could not map json file: {}", json);
} catch (JsonParseException e) {
log.log(Level.WARNING, "Could not parse json file:" + json);
log.warn("Could not parse json file: {}", json);
} catch (IOException e) {
log.log(Level.WARNING, "Could not read json file:" + json);
log.warn("Could not read json file: {}", json);
}

return features;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ public interface BaseRenderer {

void setI18n(I18nLoader i18nProvider);

/** @deprecated Use renderX calls that pass the documentBuilder as a parameter instead */
/**
* @param documentBuilder the instance to use
* @deprecated Use renderX calls that pass the documentBuilder as a parameter instead
*/
@Deprecated
void setDocumentBuilder(CukedoctorDocumentBuilder documentBuilder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
/** Created by pestano on 28/02/16. */
public interface ExamplesRenderer extends BaseRenderer {

/** @deprecated Use renderScenarioExamples(Scenario, CukedoctorDocumentBuilder) instead */
/**
* @param scenario the scenario containing the examples
* @return the renderer {@link String}
* @deprecated Use renderScenarioExamples(Scenario, CukedoctorDocumentBuilder) instead
*/
@Deprecated
String renderScenarioExamples(Scenario scenario);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
/** Created by pestano on 24/02/16. */
public interface FeatureRenderer extends BaseRenderer {

/** @deprecated Use renderFeature(Feature, CukedoctorDocumentBuilder) instead */
/**
* @param feature the feature to render
* @return the rendered {@link String}
* @deprecated Use renderFeature(Feature, CukedoctorDocumentBuilder) instead
*/
@Deprecated
String renderFeature(Feature feature);

Expand All @@ -17,7 +21,11 @@ default String renderFeature(Feature feature, CukedoctorDocumentBuilder document
return renderFeature(feature);
}

/** @deprecated Use renderFeatures(List&lt;Feature&gt;, CukedoctorDocumentBuilder) instead */
/**
* @param features the features to render
* @return the rendered {@link String}
* @deprecated Use renderFeatures(List&lt;Feature&gt;, CukedoctorDocumentBuilder) instead
*/
@Deprecated
String renderFeatures(List<Feature> features);

Expand Down
Loading

0 comments on commit 8a5cf9c

Please sign in to comment.