Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/checkstyle-checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@
<module name="FileLength">
<property name="fileExtensions" value="java"/>
</module>
<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="100"/>
<property name="ignorePattern"
value="^( *\* *([^ ]+|\{@code .*|&lt;a href=&quot;[^&quot;]+&quot;&gt;)|(package|import) .*)$"/>
</module>

<!-- Whitespace -->
<module name="FileTabCharacter">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class CheckstylePlugin extends Plugin {
public static final String PLUGIN_ID = "net.sf.eclipsecs.core"; //$NON-NLS-1$

/** Extension point id for Checkstyle addon providers. */
private static final String ADDON_PROVIDER_EXT_PT_ID = PLUGIN_ID + ".checkstyleAddonProvider"; //$NON-NLS-1$
private static final String ADDON_PROVIDER_EXT_PT_ID = PLUGIN_ID + ".checkstyleAddonProvider";

/**
* Platform Locale.
Expand All @@ -70,7 +70,7 @@ public void start(BundleContext context) throws Exception {
ADDON_PROVIDER_EXT_PT_ID);

try {
Logger checkstyleErrorLog = Logger.getLogger("com.puppycrawl.tools.checkstyle.ExceptionLog"); //$NON-NLS-1$
Logger checkstyleErrorLog = Logger.getLogger("com.puppycrawl.tools.checkstyle.ExceptionLog");

checkstyleErrorLog.addHandler(new EclipseLogHandler(this));
checkstyleErrorLog.setLevel(Level.ALL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class CheckstylePluginPrefs extends AbstractPreferenceInitializer {
* Preference name indicating if the number of checkstyle warning generated per file should be
* limited.
*/
public static final String PREF_LIMIT_MARKERS_PER_RESOURCE = "limit.markers.per.resource"; //$NON-NLS-1$
public static final String PREF_LIMIT_MARKERS_PER_RESOURCE = "limit.markers.per.resource";

/**
* Preference name for the preference that stores the limit of markers per resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
public class CheckstyleBuilder extends IncrementalProjectBuilder {

/** Eclipse extension point ID for the builder. */
public static final String BUILDER_ID = CheckstylePlugin.PLUGIN_ID + ".CheckstyleBuilder"; //$NON-NLS-1$
public static final String BUILDER_ID = CheckstylePlugin.PLUGIN_ID + ".CheckstyleBuilder";

/**
* Run the Checkstyle builder on all open projects in the workspace.
Expand Down Expand Up @@ -305,8 +305,8 @@ private <T extends IResource> Map<CheckConfiguration, Auditor> resolveAudits(
* @throws CoreException
* an unexpected error occurred
*/
private Collection<IResource> getResources(final IResourceDelta delta, final List<AuditFilter> filters)
throws CoreException {
private Collection<IResource> getResources(final IResourceDelta delta,
final List<AuditFilter> filters) throws CoreException {

List<IResource> resources = new ArrayList<>();

Expand Down Expand Up @@ -356,8 +356,8 @@ private Collection<IResource> getResources(final IResourceDelta delta, final Lis
* @throws CoreException
* an unexpected error occurred
*/
private Collection<IResource> getResources(final IContainer container, final List<AuditFilter> filters)
throws CoreException {
private Collection<IResource> getResources(final IContainer container,
final List<AuditFilter> filters) throws CoreException {

List<IResource> resources = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
public final class CheckstyleMarker {
/** ID for the CheckstyleMarker. */
public static final String MARKER_ID = CheckstylePlugin.PLUGIN_ID + ".CheckstyleMarker"; //$NON-NLS-1$
public static final String MARKER_ID = CheckstylePlugin.PLUGIN_ID + ".CheckstyleMarker";

/** Module name key in marker attributes. */
public static final String MODULE_NAME = "ModuleName"; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ private CheckConfigurationTester() {
* @throws CheckstylePluginException
* most likely the configuration file could not be found
*/
public static List<ResolvableProperty> getUnresolvedProperties(CheckConfiguration checkConfiguration)
throws CheckstylePluginException {
public static List<ResolvableProperty> getUnresolvedProperties(
CheckConfiguration checkConfiguration) throws CheckstylePluginException {

CheckstyleConfigurationFile configFile = checkConfiguration.getCheckstyleConfiguration();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public CheckConfigurationWorkingCopy(ConfigurationType configType,
CheckConfigurationWorkingSet workingSet, boolean global) {

mWorkingSet = workingSet;
mCheckConfiguration = new DefaultCheckConfiguration(null, null, null, configType, global, null, null);
mCheckConfiguration = new DefaultCheckConfiguration(null, null, null, configType, global, null,
null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ private ConfigurationReader() {
}

/**
* Reads the checkstyle configuration from the given stream and returns a list of all modules within
* this configuration.
* Reads the checkstyle configuration from the given stream and returns a list of all modules
* within this configuration.
*
* @param input
* the stream the configuration is loaded from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ public static void write(OutputStream out, List<Module> modules, CheckConfigurat

String lineSeperator = System.lineSeparator();

String comment = lineSeperator
+ " This configuration file was written by the eclipse-cs plugin configuration editor" //$NON-NLS-1$
+ lineSeperator;
String comment = lineSeperator + " This configuration file was written by "
+ "the eclipse-cs plugin configuration editor" + lineSeperator;
doc.addComment(comment);

// write out name and description as comment
Expand Down Expand Up @@ -231,12 +230,11 @@ private static Element writeModule(Module module, Branch parent) {
* @return the list of child modules
*/
private static List<Module> getChildModules(Module module, List<Module> remainingModules) {

List<Module> childModules = new ArrayList<>();

for (Module tmp : remainingModules) {

String parentInternalName = module != null ? module.getMetaData().identity().internalName() : null;
String parentInternalName = module != null ? module.getMetaData().identity().internalName()
: null;
String childParent = tmp.getMetaData().identity().parent();

// only the checker module has no parent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public class DefaultCheckConfiguration extends AbstractCheckConfiguration {
* @param additionalData
* a map of additional data for this configuration
*/
public DefaultCheckConfiguration(final String name, final String location, final String description,
final ConfigurationType type, final boolean global,
public DefaultCheckConfiguration(final String name, final String location,
final String description, final ConfigurationType type, final boolean global,
final List<ResolvableProperty> properties, final Map<String, String> additionalData) {
mName = name;
mLocation = location;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,11 @@ public final class XmlTags {
public static final String TREEWALKER_MODULE = "TreeWalker"; //$NON-NLS-1$

/** Constant for the name of the SuppressionCommentFiler module. */
public static final String SUPRESSIONCOMMENTFILTER_MODULE = "SuppressionCommentFilter"; //$NON-NLS-1$
public static final String SUPRESSIONCOMMENTFILTER_MODULE = "SuppressionCommentFilter";

/** Constant for the name of the SuppressWithNearbyCommentFilter module. */
public static final String SUPRESSWITHNEARBYCOMMENTFILTER_MODULE = "SuppressWithNearbyCommentFilter"; //$NON-NLS-1$
public static final String SUPRESSWITHNEARBYCOMMENTFILTER_MODULE =
"SuppressWithNearbyCommentFilter";

/** Constant for the name of the SuppressWarningsHolder module. */
public static final String SUPPRESSWARNINGSHOLDER_MODULE = "SuppressWarningsHolder"; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public boolean isConfigurable(CheckConfiguration checkConfiguration) {

boolean isConfigurable = true;

boolean isProtected = Boolean.parseBoolean(checkConfiguration.getAdditionalData().get(KEY_PROTECT_CONFIG));
boolean isProtected = Boolean
.parseBoolean(checkConfiguration.getAdditionalData().get(KEY_PROTECT_CONFIG));
isConfigurable = !isProtected;

if (!isProtected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ protected URL resolveLocation(CheckConfiguration checkConfiguration) throws IOEx
public boolean isConfigurable(CheckConfiguration checkConfiguration) {
boolean isConfigurable = true;

boolean isProtected = Boolean.parseBoolean(checkConfiguration.getAdditionalData().get(KEY_PROTECT_CONFIG));
boolean isProtected = Boolean
.parseBoolean(checkConfiguration.getAdditionalData().get(KEY_PROTECT_CONFIG));
isConfigurable = !isProtected;

if (!isProtected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class RemoteConfigurationType extends AbstractConfigurationType {
public static final String KEY_CACHE_FILE_LOCATION = "cache-file-location"; //$NON-NLS-1$

/** Key to access the path of the cached property file. */
public static final String KEY_CACHE_PROPS_FILE_LOCATION = "cache-props-file-location"; //$NON-NLS-1$
public static final String KEY_CACHE_PROPS_FILE_LOCATION = "cache-props-file-location";

/** Key to access the username. */
public static final String KEY_USERNAME = "username"; //$NON-NLS-1$
Expand All @@ -83,7 +83,8 @@ public class RemoteConfigurationType extends AbstractConfigurationType {
public CheckstyleConfigurationFile getCheckstyleConfiguration(
CheckConfiguration checkConfiguration) throws CheckstylePluginException {

boolean useCacheFile = Boolean.parseBoolean(checkConfiguration.getAdditionalData().get(KEY_CACHE_CONFIG));
boolean useCacheFile = Boolean
.parseBoolean(checkConfiguration.getAdditionalData().get(KEY_CACHE_CONFIG));

CheckstyleConfigurationFile data = new CheckstyleConfigurationFile();

Expand Down Expand Up @@ -187,7 +188,8 @@ public void notifyCheckConfigRemoved(CheckConfiguration checkConfiguration)
RemoteConfigAuthenticator
.removeCachedAuthInfo(checkConfiguration.getResolvedConfigurationFileUrl());

boolean useCacheFile = Boolean.parseBoolean(checkConfiguration.getAdditionalData().get(KEY_CACHE_CONFIG));
boolean useCacheFile = Boolean
.parseBoolean(checkConfiguration.getAdditionalData().get(KEY_CACHE_CONFIG));

if (useCacheFile) {
// remove the cached configuration file from the workspace metadata
Expand Down Expand Up @@ -442,9 +444,9 @@ private static String getSecureStoragePath(URL resolvedCheckConfigurationUrl)
String urlHash = null;

try {

MessageDigest digest = MessageDigest.getInstance("MD5");
byte[] hash = digest.digest(resolvedCheckConfigurationUrl.toExternalForm().getBytes("UTF-8"));
byte[] hash = digest
.digest(resolvedCheckConfigurationUrl.toExternalForm().getBytes("UTF-8"));
urlHash = EncodingUtils.encodeBase64(hash);

urlHash = urlHash.replace('/', '_');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public static String getModifiableTokens(String checkName) {
String result = null;
if (AbstractJavadocCheck.class.isAssignableFrom(checkResult.getClass())) {
final AbstractJavadocCheck javadocCheck = (AbstractJavadocCheck) checkResult;
final List<Integer> modifiableJavadocTokens = subtractTokens(javadocCheck.getAcceptableJavadocTokens(),
final List<Integer> modifiableJavadocTokens = subtractTokens(
javadocCheck.getAcceptableJavadocTokens(),
javadocCheck.getRequiredJavadocTokens());
result = getTokens(JavadocUtil::getTokenName, modifiableJavadocTokens);
}
Expand Down Expand Up @@ -85,7 +86,8 @@ private static List<Integer> subtractTokens(int[] tokens, int... requiredTokens)
.collect(Collectors.toList());
}

private static String getTokens(Function<Integer, String> function, List<Integer> modifiableTokens) {
private static String getTokens(Function<Integer, String> function,
List<Integer> modifiableTokens) {
return modifiableTokens.stream()
.map(function::apply)
.collect(Collectors.joining(","));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public List<RuleMetadata> loadRuleMetadata(
final String ruleDescription = thirdPartyGroups.get(lookupKey).get("description");
final int rulePriority = Integer.parseInt(thirdPartyGroups.get(lookupKey)
.get("priority"));
group = new RuleGroupMetadata(ruleGroupName, ruleGroupName, ruleDescription, false, rulePriority);
group = new RuleGroupMetadata(ruleGroupName, ruleGroupName, ruleDescription, false,
rulePriority);
groups.put(ruleGroupName, group);
}
}
Expand All @@ -106,7 +107,8 @@ private RuleMetadata createRuleMetadata(RuleGroupMetadata group, ModuleDetails m
final String[] packageTokens = moduleDetails.getParent().split(DOT_PATTERN);
List<String> alternativeNames = List.of(moduleDetails.getFullQualifiedName());
List<ConfigPropertyMetadata> properties = moduleDetails.getProperties().stream()
.map(modulePropertyDetails -> createPropertyConfig(moduleDetails, modulePropertyDetails))
.map(modulePropertyDetails -> createPropertyConfig(moduleDetails,
modulePropertyDetails))
.toList();
RuleMetadata ruleMeta = new RuleMetadata(
new RuleIdentity(moduleDetails.getName(), moduleDetails.getName(),
Expand Down Expand Up @@ -163,7 +165,8 @@ private ConfigPropertyMetadata createPropertyConfig(ModuleDetails moduleDetails,
resultList.forEach(modifiedConfigPropertyMetadata.getPropertyEnumeration()::add);
} else if (dataType == ConfigPropertyType.MULTI_CHECK) {
String result = CheckUtil.getModifiableTokens(moduleDetails.getName());
Collections.addAll(modifiedConfigPropertyMetadata.getPropertyEnumeration(), result.split(","));
Collections.addAll(modifiedConfigPropertyMetadata.getPropertyEnumeration(),
result.split(","));
}
return modifiedConfigPropertyMetadata;

Expand Down Expand Up @@ -198,7 +201,8 @@ private static List<String> getEnumValues(String className) {
* {@code sThirdPartyRuleGroupMap}.
* @param thirdPartyGroups
*/
private static String findLookupKey(Map<String, Map<String, String>> thirdPartyGroups, String packageName) {
private static String findLookupKey(Map<String, Map<String, String>> thirdPartyGroups,
String packageName) {
final String[] packageTokens = packageName.split(DOT_PATTERN);
List<String> prefixList = new ArrayList<>();
String lookupKey = packageTokens[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,17 @@ private static void registerAlternativeNames(RuleMetadata ruleMetadata) {
}

/**
* Create repository of Module Details from checkstyle metadata and third party extension checks metadata.
* Create repository of Module Details from checkstyle metadata and third party extension checks
* metadata.
*/
private static void createMetadataMap() {
List<ModuleDetails> moduleDetails = XmlMetaReader.readAllModulesIncludingThirdPartyIfAny(sPackageNameSet.toArray(new String[0]));
List<ModuleDetails> moduleDetails = XmlMetaReader
.readAllModulesIncludingThirdPartyIfAny(sPackageNameSet.toArray(new String[0]));
if (moduleDetails.isEmpty()) {
CheckstyleLog.log(null, "Cannot read module details");
}
moduleDetails.forEach(moduleDetail -> sModuleDetailsRepo.put(moduleDetail.getName(), moduleDetail));
moduleDetails
.forEach(moduleDetail -> sModuleDetailsRepo.put(moduleDetail.getName(), moduleDetail));
}

/**
Expand Down Expand Up @@ -446,15 +449,16 @@ private static ResourceBundle getMetadataI18nBundle(String metadataFile,
ResourceBundle resourceBundle;
String bundle = metadataFile.substring(0, metadataFile.length() - 4).replace('/', '.');
try {
resourceBundle = ResourceBundle.getBundle(bundle, CheckstylePlugin.getPlatformLocale(), classLoader);
resourceBundle = ResourceBundle.getBundle(bundle, CheckstylePlugin.getPlatformLocale(),
classLoader);
} catch (MissingResourceException ex) {
resourceBundle = null;
}
return resourceBundle;
}

private static void parseMetadata(InputStream metadataStream, ResourceBundle metadataBundle, String groupId)
throws DocumentException, CheckstylePluginException {
private static void parseMetadata(InputStream metadataStream, ResourceBundle metadataBundle,
String groupId) throws DocumentException, CheckstylePluginException {
Collection<RuleGroupMetadata> groups = MetadataXmlReader.parseMetadata(metadataStream,
metadataBundle, groupId);
groups.forEach(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ public static Collection<RuleGroupMetadata> parseMetadata(InputStream metadataSt
return groups.values();
}

private static List<RuleMetadata> processModules(Element groupElement, RuleGroupMetadata groupMetadata,
ResourceBundle metadataBundle) throws CheckstylePluginException {
private static List<RuleMetadata> processModules(Element groupElement,
RuleGroupMetadata groupMetadata, ResourceBundle metadataBundle)
throws CheckstylePluginException {
List<RuleMetadata> modules = new ArrayList<>();

List<Element> moduleElements = groupElement.elements(XmlTags.RULE_METADATA_TAG);
Expand All @@ -120,7 +121,7 @@ private static List<RuleMetadata> processModules(Element groupElement, RuleGroup
: null;
boolean hidden = Boolean.parseBoolean(moduleEl.attributeValue(XmlTags.HIDDEN_TAG));
boolean hasSeverity = !"false".equals(moduleEl.attributeValue(XmlTags.HAS_SEVERITY_TAG));
boolean deletable = !"false".equals(moduleEl.attributeValue(XmlTags.DELETABLE_TAG)); //$NON-NLS-1$
boolean deletable = !"false".equals(moduleEl.attributeValue(XmlTags.DELETABLE_TAG));
boolean isSingleton = Boolean.parseBoolean(moduleEl.attributeValue(XmlTags.IS_SINGLETON_TAG));

// process description
Expand Down Expand Up @@ -204,7 +205,8 @@ private static List<ConfigPropertyMetadata> processProperties(Element moduleElem

if (OptionProvider.class.isAssignableFrom(providerClass)) {

OptionProvider provider = (OptionProvider) providerClass.getDeclaredConstructor().newInstance();
OptionProvider provider = (OptionProvider) providerClass.getDeclaredConstructor()
.newInstance();
property.getPropertyEnumeration().addAll(provider.getOptions());
} else if (Enum.class.isAssignableFrom(providerClass)) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public class RuleGroupMetadata {
/** The list of modules belonging to the group. */
private List<RuleMetadata> mRuleMetadata = new LinkedList<>();

RuleGroupMetadata(String groupId, String groupName, String groupDesc, boolean hidden, int priority) {
RuleGroupMetadata(String groupId, String groupName, String groupDesc, boolean hidden,
int priority) {
mGroupId = groupId;
mGroupName = groupName;
mDescription = groupDesc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import java.util.List;

public record RuleIdentity(String ruleName, String internalName, String parent, RuleGroupMetadata group,
String description, List<String> alternativeNames) {
public record RuleIdentity(String ruleName, String internalName, String parent,
RuleGroupMetadata group, String description, List<String> alternativeNames) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
public final class SaveFilters {

/** constant for the extension point id. */
private static final String FILTER_EXTENSION_POINT = CheckstylePlugin.PLUGIN_ID + ".saveFilters"; //$NON-NLS-1$
private static final String FILTER_EXTENSION_POINT = CheckstylePlugin.PLUGIN_ID + ".saveFilters";

/** constant for the class attribute. */
private static final String ATTR_CLASS = "class"; //$NON-NLS-1$
Expand Down
Loading
Loading