Skip to content

Commit

Permalink
minor: increase code coverage for meta data packages
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach authored and romani committed Sep 26, 2021
1 parent 36367dd commit 2a10e80
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 37 deletions.
21 changes: 3 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.93</minimum>
<minimum>0.91</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
Expand All @@ -1082,27 +1082,12 @@
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.74</minimum>
<minimum>0.96</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.71</minimum>
</limit>
</limits>
</rule>
<rule>
<element>CLASS</element>
<includes>
<include>
com.puppycrawl.tools.checkstyle.meta.ModuleDetails
</include>
</includes>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.76</minimum>
<minimum>1.00</minimum>
</limit>
</limits>
</rule>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,14 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/** Simple POJO class for module details. */
public final class ModuleDetails {

/** List of properties of the module. */
private final List<ModulePropertyDetails> properties = new ArrayList<>();

/** Properties of the module arranged in a map where key is property name. */
private final Map<String, ModulePropertyDetails> modulePropertyKeyMap = new HashMap<>();

/** List of violation message keys of the module. */
private final List<String> violationMessageKeys = new ArrayList<>();

Expand Down Expand Up @@ -140,7 +135,6 @@ public List<ModulePropertyDetails> getProperties() {
*/
public void addToProperties(ModulePropertyDetails property) {
properties.add(property);
modulePropertyKeyMap.put(property.getName(), property);
}

/**
Expand All @@ -150,9 +144,6 @@ public void addToProperties(ModulePropertyDetails property) {
*/
public void addToProperties(List<ModulePropertyDetails> modulePropertyDetailsList) {
properties.addAll(modulePropertyDetailsList);
modulePropertyDetailsList.forEach(modulePropertyDetails -> {
modulePropertyKeyMap.put(modulePropertyDetails.getName(), modulePropertyDetails);
});
}

/**
Expand Down Expand Up @@ -182,16 +173,6 @@ public void addToViolationMessages(List<String> msgList) {
violationMessageKeys.addAll(msgList);
}

/**
* Get a module property object by supplying its name as key.
*
* @param key module property name
* @return module property object
*/
public ModulePropertyDetails getModulePropertyByKey(String key) {
return modulePropertyKeyMap.get(key);
}

/**
* Get module type.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ protected String getPackageLocation() {
return "com/puppycrawl/tools/checkstyle/meta/xmlmetareader";
}

@Test
public void test() {
assertThat(XmlMetaReader.readAllModulesIncludingThirdPartyIfAny().size()).isEqualTo(198);
}

@Test
public void testDuplicatePackage() {
assertThat(XmlMetaReader
.readAllModulesIncludingThirdPartyIfAny("com.puppycrawl.tools.checkstyle.meta")
.size()).isEqualTo(198);
}

@Test
public void testReadXmlMetaCheckWithProperties() throws Exception {
final String path = getPath("InputXmlMetaReaderCheckWithProps.xml");
Expand Down

0 comments on commit 2a10e80

Please sign in to comment.