Skip to content

Commit

Permalink
CHECKSTYLE: Ensure methods have this qualifier (#359)
Browse files Browse the repository at this point in the history
* CHECKSTYLE: Ensure methods have  qualifier

Signed-off-by: Taylor Smock <[email protected]>

* CHECKSTYLE: Add  qualifier to method calls where needed

Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock authored Sep 21, 2020
1 parent 3a5c6f2 commit 72fd853
Show file tree
Hide file tree
Showing 60 changed files with 356 additions and 347 deletions.
2 changes: 1 addition & 1 deletion config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
<module name="PackageDeclaration"/>
<module name="ParameterAssignment"/>
<module name="RequireThis">
<property name="checkMethods" value="false"/>
<property name="checkMethods" value="true"/>
<property name="validateOnlyOverlapping" value="false"/>
</module>
<module name="SimplifyBooleanExpression" />
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/org/openstreetmap/atlas/checks/base/BaseCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ public abstract class BaseCheck<T> implements Check, Serializable
*/
public BaseCheck(final Configuration configuration)
{
this.acceptPiers = configurationValue(configuration, PARAMETER_ACCEPT_PIERS, false);
this.countries = Collections.unmodifiableList(configurationValue(configuration,
this.acceptPiers = this.configurationValue(configuration, PARAMETER_ACCEPT_PIERS, false);
this.countries = Collections.unmodifiableList(this.configurationValue(configuration,
PARAMETER_PERMITLIST_COUNTRIES, Collections.emptyList()));
this.denylistCountries = Collections.unmodifiableList(configurationValue(configuration,
this.denylistCountries = Collections.unmodifiableList(this.configurationValue(configuration,
PARAMETER_DENYLIST_COUNTRIES, Collections.emptyList()));
this.tagFilter = TaggableFilter
.forDefinition(configurationValue(configuration, PARAMETER_PERMITLIST_TAGS, ""));
final Map<String, String> challengeMap = configurationValue(configuration,
this.tagFilter = TaggableFilter.forDefinition(
this.configurationValue(configuration, PARAMETER_PERMITLIST_TAGS, ""));
final Map<String, String> challengeMap = this.configurationValue(configuration,
PARAMETER_CHALLENGE, Collections.emptyMap());
this.flagLanguageMap = configurationValue(configuration, PARAMETER_FLAG,
this.flagLanguageMap = this.configurationValue(configuration, PARAMETER_FLAG,
Collections.emptyMap());
this.locale = configurationValue(configuration, PARAMETER_LOCALE_KEY,
this.locale = this.configurationValue(configuration, PARAMETER_LOCALE_KEY,
DEFAULT_LOCALE.getLanguage(), Locale::new);
if (challengeMap.isEmpty())
{
Expand All @@ -103,14 +103,14 @@ public BaseCheck(final Configuration configuration)
}
this.globalPolygonFilter = AtlasEntityPolygonsFilter.forConfiguration(configuration);
this.checkPolygonFilter = AtlasEntityPolygonsFilter.forConfigurationValues(
configurationValue(configuration, AtlasEntityPolygonsFilter.INCLUDED_POLYGONS_KEY,
Collections.emptyMap()),
configurationValue(configuration,
this.configurationValue(configuration,
AtlasEntityPolygonsFilter.INCLUDED_POLYGONS_KEY, Collections.emptyMap()),
this.configurationValue(configuration,
AtlasEntityPolygonsFilter.INCLUDED_MULTIPOLYGONS_KEY,
Collections.emptyMap()),
configurationValue(configuration, AtlasEntityPolygonsFilter.EXCLUDED_POLYGONS_KEY,
Collections.emptyMap()),
configurationValue(configuration,
this.configurationValue(configuration,
AtlasEntityPolygonsFilter.EXCLUDED_POLYGONS_KEY, Collections.emptyMap()),
this.configurationValue(configuration,
AtlasEntityPolygonsFilter.EXCLUDED_MULTIPOLYGONS_KEY,
Collections.emptyMap()));
}
Expand Down Expand Up @@ -150,7 +150,7 @@ public final Predicate<AtlasObject> checkObjectFilter()
@Override
public void clear()
{
clearFlaggedIdentifiers();
this.clearFlaggedIdentifiers();
}

@Override
Expand Down Expand Up @@ -293,7 +293,7 @@ protected void clearFlaggedIdentifiers()

protected final String configurationKey(final Class<?> type, final String key)
{
return formatKey(type.getSimpleName(), key);
return this.formatKey(type.getSimpleName(), key);
}

/**
Expand All @@ -305,19 +305,19 @@ protected final String configurationKey(final Class<?> type, final String key)
*/
protected final String configurationKey(final String key)
{
return formatKey(getCheckName(), key);
return this.formatKey(this.getCheckName(), key);
}

protected <U> U configurationValue(final Configuration configuration, final String key,
final U defaultValue)
{
return configuration.get(configurationKey(key), defaultValue).value();
return configuration.get(this.configurationKey(key), defaultValue).value();
}

protected <U, V> V configurationValue(final Configuration configuration, final String key,
final U defaultValue, final Function<U, V> transform)
{
return configuration.get(configurationKey(key), defaultValue, transform).value();
return configuration.get(this.configurationKey(key), defaultValue, transform).value();
}

protected CheckFlag createFlag(final AtlasObject object, final String instruction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ public Configuration getConfigurationForCountry(final String country)

public <T extends Check> Set<T> loadChecks(final Predicate<Class> isEnabled)
{
return loadChecks(isEnabled, this.configuration);
return this.loadChecks(isEnabled, this.configuration);
}

public <T extends Check> Set<T> loadChecks(final Configuration configuration)
{
return loadChecks(this::isEnabledByConfiguration, configuration);
return this.loadChecks(this::isEnabledByConfiguration, configuration);
}

/**
Expand Down Expand Up @@ -178,13 +178,13 @@ public <T extends Check> Set<T> loadChecks(final Predicate<Class> isEnabled,
*/
public <T extends Check> Set<T> loadChecks()
{
return loadChecks(this::isEnabledByConfiguration, this.configuration);
return this.loadChecks(this::isEnabledByConfiguration, this.configuration);
}

public <T extends Check> Set<T> loadChecksForCountry(final String country)
{
final Configuration countryConfiguration = this.getConfigurationForCountry(country);
return loadChecks(checkClass -> this.isEnabledByConfiguration(countryConfiguration,
return this.loadChecks(checkClass -> this.isEnabledByConfiguration(countryConfiguration,
checkClass, country), countryConfiguration);
}

Expand Down Expand Up @@ -303,7 +303,7 @@ private <T extends Check> Optional<T> initializeCheckWithArguments(final Class<T

private boolean isEnabledByConfiguration(final Class checkClass)
{
return isEnabledByConfiguration(this.configuration, checkClass);
return this.isEnabledByConfiguration(this.configuration, checkClass);
}

private boolean isEnabledByConfiguration(final Configuration configuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ public int execute()
// Write the counts for the input logs is requested
if (outputTypes.contains(OutputTypes.RUN_SUMMARY.toString()))
{
this.writeCSV(outputFolder + "/runSummary.csv", generateFullOutput(inputCounts));
this.writeCSV(outputFolder + "/runSummary.csv",
this.generateFullOutput(inputCounts));
}
// Generate the totals output
List<List<String>> totalsOutput = generateTotalsOutput(inputCounts);
List<List<String>> totalsOutput = this.generateTotalsOutput(inputCounts);
// Generate the counts output if requested
List<List<String>> countsOutput = generateCountsOutput(inputCounts);
List<List<String>> countsOutput = this.generateCountsOutput(inputCounts);

// Get the optional reference input
final Optional<String> referenceFilePath = this.optionAndArgumentDelegate
Expand All @@ -132,14 +133,14 @@ public int execute()
if (outputTypes.contains(OutputTypes.RUN_SUMMARY.toString()))
{
this.writeCSV(outputFolder + "/runSummaryDifference.csv",
generateFullOutput(differenceCounts));
this.generateFullOutput(differenceCounts));
}

// Add the reference and difference metrics to the totals output
totalsOutput = addReferenceAndDifferenceToTotalsOutput(totalsOutput,
totalsOutput = this.addReferenceAndDifferenceToTotalsOutput(totalsOutput,
referenceCounts, differenceCounts);
// Add the reference and difference metrics to the counts output
countsOutput = addReferenceAndDifferenceToCountsOutput(countsOutput,
countsOutput = this.addReferenceAndDifferenceToCountsOutput(countsOutput,
referenceCounts, differenceCounts);
}

Expand Down Expand Up @@ -232,15 +233,16 @@ private List<List<String>> addReferenceAndDifferenceToCountsOutput(
for (int index = 1; index < outputLines.size(); index++)
{
// Get the reference value for the country and check
final Optional<Long> referenceCount = getCountryCheckCount(referenceCountryCheckCounts,
stage1Output.get(index).get(0), stage1Output.get(index).get(1));
final Optional<Long> referenceCount = this.getCountryCheckCount(
referenceCountryCheckCounts, stage1Output.get(index).get(0),
stage1Output.get(index).get(1));
// Append the value or an empty string
stage1Output.get(index).add(2,
referenceCount.isPresent() ? String.valueOf(referenceCount.get())
: EMPTY_STRING);

// Get the difference value for the country and check
final Optional<Long> differenceCount = getCountryCheckCount(diffCountryCheckCounts,
final Optional<Long> differenceCount = this.getCountryCheckCount(diffCountryCheckCounts,
stage1Output.get(index).get(0), stage1Output.get(index).get(1));
// Append the value or an empty string
stage1Output.get(index)
Expand Down Expand Up @@ -285,10 +287,10 @@ private List<List<String>> addReferenceAndDifferenceToTotalsOutput(
final String check = outputLines.get(index).get(0);
// Add the reference total
outputLines.get(index).add(1,
String.valueOf(getCheckTotal(referenceCountryCheckCounts, check)));
String.valueOf(this.getCheckTotal(referenceCountryCheckCounts, check)));
// Add the difference total
outputLines.get(index)
.add(String.valueOf(getCheckTotal(diffCountryCheckCounts, check)));
.add(String.valueOf(this.getCheckTotal(diffCountryCheckCounts, check)));
}

return outputLines;
Expand Down Expand Up @@ -334,7 +336,8 @@ private List<List<String>> generateCountsOutput(
countryCheckRow.add(check);

// Get the optional country check count
final Optional<Long> count = getCountryCheckCount(countryCheckCounts, country, check);
final Optional<Long> count = this.getCountryCheckCount(countryCheckCounts, country,
check);
if (count.isPresent())
{
// If present add the value
Expand Down Expand Up @@ -390,7 +393,7 @@ private List<List<String>> generateFullOutput(
// Get the value of the check for each country
checkRow.addAll(countries.stream().map(country ->
{
final Optional<Long> count = getCountryCheckCount(countryCheckCounts, country,
final Optional<Long> count = this.getCountryCheckCount(countryCheckCounts, country,
check);

if (count.isPresent())
Expand All @@ -401,7 +404,7 @@ private List<List<String>> generateFullOutput(
return EMPTY_STRING;
}).collect(Collectors.toList()));
// Get the total count for this check across all countries
checkRow.add(String.valueOf(getCheckTotal(countryCheckCounts, check)));
checkRow.add(String.valueOf(this.getCheckTotal(countryCheckCounts, check)));
outputLines.add(checkRow);
});

Expand Down Expand Up @@ -455,7 +458,7 @@ private List<List<String>> generateTotalsOutput(
// Add the check name
checkRow.add(check);
// Add the total count
checkRow.add(String.valueOf(getCheckTotal(countryCheckCounts, check)));
checkRow.add(String.valueOf(this.getCheckTotal(countryCheckCounts, check)));
outputLines.add(checkRow);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ public int execute(final CommandMap command)
.getOption(OUTPUT_FOLDER_PARAMETER);
if (output.isPresent())
{
writeSetToGeoJSON(additions,
this.writeSetToGeoJSON(additions,
new File(String.format("%s/additions-%d-%d.%s", output.get(),
new Date().getTime(), this.countMapValues(additions),
this.fileExtension)));
writeSetToGeoJSON(subtractions,
this.writeSetToGeoJSON(subtractions,
new File(String.format("%s/subtractions-%d-%d.%s", output.get(),
new Date().getTime(), this.countMapValues(subtractions),
this.fileExtension)));
Expand Down Expand Up @@ -197,9 +197,9 @@ protected Map<String, Map<Set<String>, JsonObject>> getReference()
protected int getReferenceSize()
{
int sourceSize = 0;
for (final String check : getReference().keySet())
for (final String check : this.getReference().keySet())
{
sourceSize += getReference().get(check).size();
sourceSize += this.getReference().get(check).size();
}
return sourceSize;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public Atlas getAtlas()
*/
public Atlas load(final String input, final String country)
{
return load(input, country, intermediateAtlas ->
return this.load(input, country, intermediateAtlas ->
{
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ public String getName()
public void start(final CommandMap commandMap)
{
final String atlasDirectory = (String) commandMap.get(ATLAS_FOLDER);
final String input = Optional.ofNullable(input(commandMap)).orElse(atlasDirectory);
final String output = output(commandMap);
final String input = Optional.ofNullable(this.input(commandMap)).orElse(atlasDirectory);
final String output = this.output(commandMap);
@SuppressWarnings("unchecked")
final Set<OutputFormats> outputFormats = (Set<OutputFormats>) commandMap
.get(OUTPUT_FORMATS);
Expand Down Expand Up @@ -170,11 +170,11 @@ public void start(final CommandMap commandMap)
final boolean compressOutput = Boolean
.parseBoolean((String) commandMap.get(SparkJob.COMPRESS_OUTPUT));

final Map<String, String> sparkContext = configurationMap();
final Map<String, String> sparkContext = this.configurationMap();
final CheckResourceLoader checkLoader = new CheckResourceLoader(checksConfiguration);
// check configuration and country list
final Set<BaseCheck<?>> preOverriddenChecks = checkLoader.loadChecks();
if (!isValidInput(countries, preOverriddenChecks))
if (!this.isValidInput(countries, preOverriddenChecks))
{
logger.error("No countries supplied or checks enabled, exiting!");
return;
Expand Down Expand Up @@ -204,7 +204,7 @@ public void start(final CommandMap commandMap)
logger.info("Initialized checks: {}", infoMessage2);

// Parallelize on the countries
final JavaPairRDD<String, Set<BaseCheck>> countryCheckRDD = getContext()
final JavaPairRDD<String, Set<BaseCheck>> countryCheckRDD = this.getContext()
.parallelizePairs(countryCheckTuples, countryCheckTuples.size());

// Set target and temporary folders
Expand Down Expand Up @@ -378,11 +378,11 @@ public void start(final CommandMap commandMap)
@Override
protected List<String> outputToClean(final CommandMap command)
{
final String output = output(command);
final String output = this.output(command);
final List<String> staticPaths = super.outputToClean(command);
staticPaths.add(getAlternateSubFolderOutput(output, OUTPUT_FLAG_FOLDER));
staticPaths.add(getAlternateSubFolderOutput(output, OUTPUT_GEOJSON_FOLDER));
staticPaths.add(getAlternateSubFolderOutput(output, OUTPUT_ATLAS_FOLDER));
staticPaths.add(this.getAlternateSubFolderOutput(output, OUTPUT_FLAG_FOLDER));
staticPaths.add(this.getAlternateSubFolderOutput(output, OUTPUT_GEOJSON_FOLDER));
staticPaths.add(this.getAlternateSubFolderOutput(output, OUTPUT_ATLAS_FOLDER));
return staticPaths;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ public void start(final CommandMap commandMap)
{
final Time start = Time.now();
final String atlasDirectory = (String) commandMap.get(ATLAS_FOLDER);
final String input = Optional.ofNullable(input(commandMap)).orElse(atlasDirectory);
final String input = Optional.ofNullable(this.input(commandMap)).orElse(atlasDirectory);

// Gather arguments
final String output = output(commandMap);
final String output = this.output(commandMap);
@SuppressWarnings("unchecked")
final Set<OutputFormats> outputFormats = (Set<OutputFormats>) commandMap
.get(OUTPUT_FORMATS);
Expand All @@ -131,7 +131,7 @@ public void start(final CommandMap commandMap)
.orElse(ConfigurationResolver.emptyConfiguration())))
.collect(Collectors.toList()));

final Map<String, String> sparkContext = configurationMap();
final Map<String, String> sparkContext = this.configurationMap();

// File loading helpers
final AtlasFilePathResolver resolver = new AtlasFilePathResolver(checksConfiguration);
Expand Down Expand Up @@ -209,12 +209,12 @@ public void start(final CommandMap commandMap)
.format("Running checks on %s", tasksForCountry.get(0).getCountry()));

this.getContext().parallelize(tasksForCountry, tasksForCountry.size())
.mapToPair(produceFlags(input, output, this.configurationMap(),
.mapToPair(this.produceFlags(input, output, this.configurationMap(),
fileHelper, shardingBroadcast, distanceToLoadShards,
(Boolean) commandMap.get(MULTI_ATLAS)))
.reduceByKey(UniqueCheckFlagContainer::combine)
// Generate outputs
.foreach(processFlags(output, fileHelper, outputFormats));
.foreach(this.processFlags(output, fileHelper, outputFormats));
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public CheckFlagEvent(final String checkName, final CheckFlag flag)

public String asLineDelimitedGeoJsonFeatures()
{
return asLineDelimitedGeoJsonFeatures(jsonObject ->
return this.asLineDelimitedGeoJsonFeatures(jsonObject ->
{
});
}
Expand All @@ -352,8 +352,8 @@ public String asLineDelimitedGeoJsonFeatures(final Consumer<JsonObject> jsonMuta
final JsonObject flagGeoJsonFeature = this.flag.asGeoJsonFeature();
final JsonObject flagGeoJsonProperties = flagGeoJsonFeature.get("properties")
.getAsJsonObject();
flagGeoJsonProperties.addProperty("flag:check", getCheckName());
flagGeoJsonProperties.addProperty("flag:timestamp", getTimestamp().toString());
flagGeoJsonProperties.addProperty("flag:check", this.getCheckName());
flagGeoJsonProperties.addProperty("flag:timestamp", this.getTimestamp().toString());

jsonMutator.accept(flagGeoJsonFeature);

Expand Down
Loading

0 comments on commit 72fd853

Please sign in to comment.