Skip to content

Commit

Permalink
60 Apply check-style and refactor (#61)
Browse files Browse the repository at this point in the history
* Apply check-style and refactor

* Fix duplication and float parse
  • Loading branch information
fcampostato authored Jul 26, 2022
1 parent 96c22f8 commit 111d37d
Show file tree
Hide file tree
Showing 11 changed files with 2,205 additions and 692 deletions.
62 changes: 55 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.coru</groupId>
<artifactId>scc-multiapi-converter</artifactId>
<version>2.6.2</version>
<version>2.7.0</version>
<name>SCC-MultiApi-Converter</name>
<description>Generates Spring Cloud Contracts based on an OpenApi and AsyncApi document</description>
<url>https://github.com/corunet/scc-multiapi-converter</url>
Expand Down Expand Up @@ -35,7 +35,7 @@
<developer>
<id>jegarcia</id>
<name>Jose Enrique Garcia Maciñeiras</name>
<email>jegarcia@corunet.com</email>
<email>joseenrique.garcia@sngular.com</email>
<organization>Corunet</organization>
<organizationUrl>https://corunet.github.io/</organizationUrl>
<roles>
Expand All @@ -47,7 +47,7 @@
<developer>
<id>cmunozgomez</id>
<name>Cesar Munoz Gomez</name>
<email>cmunoz@corunet.com</email>
<email>cesar.munoz@sngular.com</email>
<organization>Corunet</organization>
<organizationUrl>https://corunet.github.io/</organizationUrl>
<roles>
Expand All @@ -58,7 +58,7 @@
<developer>
<id>Rivarsal</id>
<name>Pablo José López Rivadulla</name>
<email>plopez@corunet.com</email>
<email>pablo.lopezr@sngular.com</email>
<organization>Corunet</organization>
<organizationUrl>https://corunet.github.io/</organizationUrl>
<roles>
Expand All @@ -69,7 +69,7 @@
<developer>
<id>fcampostato</id>
<name>Fernando Campos Tato</name>
<email>fcampos@corunet.com</email>
<email>fernando.campos@sngular.com</email>
<organization>Corunet</organization>
<organizationUrl>https://corunet.github.io/</organizationUrl>
<roles>
Expand All @@ -80,7 +80,7 @@
<developer>
<id>jmejutovazquez</id>
<name>Javier Mejuto Vázquez</name>
<email>jmejuto@corunet.com</email>
<email>javier.mejuto@sngular.com</email>
<organization>Corunet</organization>
<organizationUrl>https://corunet.github.io/</organizationUrl>
<roles>
Expand All @@ -91,7 +91,7 @@
<developer>
<id>mcabezasp</id>
<name>Miguel Cabezas Puerto</name>
<email>mcabezas@corunet.com</email>
<email>miguel.cabezas@sngular.com</email>
<organization>Corunet</organization>
<organizationUrl>https://corunet.github.io/</organizationUrl>
<roles>
Expand Down Expand Up @@ -192,7 +192,43 @@
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>styles/checkstyle/OSS_checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
<executions>
<execution>
<id>validate</id>
<goals>
<goal>check</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
Expand Down Expand Up @@ -287,4 +323,16 @@
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>styles/checkstyle/OSS_checkstyle.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.springframework.cloud.contract.spec.ContractConverter;

@Slf4j
public class MultiApiContractConverter implements ContractConverter<Collection<Contract>> {
public final class MultiApiContractConverter implements ContractConverter<Collection<Contract>> {

private static final OpenApiContractConverter OPEN_API_CONTRACT_CONVERTER = new OpenApiContractConverter();

Expand All @@ -35,8 +35,8 @@ public boolean isAccepted(final File file) {
try {
final JsonNode node;
node = BasicTypeConstants.OBJECT_MAPPER.readTree(file);
isAccepted = (node != null && node.size() > 0 && (Objects.nonNull(node.get(BasicTypeConstants.ASYNCAPI)) || Objects.nonNull(node.get(BasicTypeConstants.OPENAPI))));
} catch (IOException e) {
isAccepted = node != null && node.size() > 0 && (Objects.nonNull(node.get(BasicTypeConstants.ASYNCAPI)) || Objects.nonNull(node.get(BasicTypeConstants.OPENAPI)));
} catch (final IOException e) {
isAccepted = false;
}
}
Expand All @@ -47,7 +47,7 @@ public boolean isAccepted(final File file) {
public Collection<Contract> convertFrom(final File file) {

Collection<Contract> contracts = null;
JsonNode node;
final JsonNode node;
if (isAccepted(file)) {
try {
node = BasicTypeConstants.OBJECT_MAPPER.readTree(file);
Expand All @@ -60,13 +60,15 @@ public Collection<Contract> convertFrom(final File file) {
} else {
throw new MultiApiContractConverterException("Yaml file is not correct");
}
} catch (IOException e) {
} catch (final IOException e) {
throw new MultiApiContractConverterException(e);
}
}
return contracts;
}

@Override
public Collection<Contract> convertTo(final Collection<Contract> contract) {return contract;}
public Collection<Contract> convertTo(final Collection<Contract> contract) {
return contract;
}
}
Loading

0 comments on commit 111d37d

Please sign in to comment.