Skip to content
Merged
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
3 changes: 3 additions & 0 deletions config/checkstyle-checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,9 @@
<module name="CatchParameterName">
<property name="format" value="^(ex|[a-z][a-z][a-zA-Z]+)$"/>
</module>
<module name="StaticVariableName">
<property name="format" value="^(?:id|[a-z][a-z0-9][a-zA-Z0-9]+)$"/>
</module>
<module name="TypeName"/>
<module name="PatternVariableName"/>
<module name="IllegalIdentifierName"/>
Expand Down
1 change: 1 addition & 0 deletions config/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
<!-- NLS -->
<suppress files="Messages.java" checks="VisibilityModifier"/>
<suppress files="Messages.java" checks="JavadocVariable"/>
<suppress files="Messages.java" checks="StaticVariableName" />

<!-- temporal suppression due to leak -->
<suppress checks="JavadocVariable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class CheckstylePlugin extends Plugin {
private static Locale platformLocale;

/** The shared instance. */
private static CheckstylePlugin sPlugin;
private static CheckstylePlugin plugin;

/** The addon extension class loader. */
private ClassLoader mAddonExtensionClassLoader;
Expand All @@ -59,7 +59,7 @@ public class CheckstylePlugin extends Plugin {
* The constructor.
*/
public CheckstylePlugin() {
sPlugin = this;
plugin = this;
}

@Override
Expand All @@ -82,7 +82,7 @@ public void start(BundleContext context) throws Exception {
* @return The shared plug-in instance.
*/
public static CheckstylePlugin getDefault() {
return sPlugin;
return plugin;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,17 @@
public final class CheckerFactory {

/** Map containing the configured checkers. */
private static Cache<String, Checker> sCheckerMap;
private static final Cache<String, Checker> CHECKERS;

/** Map containing the modification times of configs. */
private static Map<String, Long> sModifiedMap;
private static final Map<String, Long> MODIFIED_TIME;

/*
* Initialize the cache.
*/
static {

sCheckerMap = CacheBuilder.newBuilder().softValues().build();

sModifiedMap = new ConcurrentHashMap<>();
CHECKERS = CacheBuilder.newBuilder().softValues().build();
MODIFIED_TIME = new ConcurrentHashMap<>();
}

/**
Expand Down Expand Up @@ -127,8 +125,8 @@ public static Checker createChecker(ICheckConfiguration config, IProject project

// store checker in cache
final Long modified = Long.valueOf(configFileData.getModificationStamp());
sCheckerMap.put(cacheKey, checker);
sModifiedMap.put(cacheKey, modified);
CHECKERS.put(cacheKey, checker);
MODIFIED_TIME.put(cacheKey, modified);
}
else {
setLocaleIfChanged(checker);
Expand All @@ -141,8 +139,8 @@ public static Checker createChecker(ICheckConfiguration config, IProject project
* Cleans up the checker cache.
*/
public static void cleanup() {
sCheckerMap.invalidateAll();
sModifiedMap.clear();
CHECKERS.invalidateAll();
MODIFIED_TIME.clear();
}

/**
Expand Down Expand Up @@ -184,20 +182,20 @@ private static String getCacheKey(ICheckConfiguration config, IProject project)
private static Checker tryCheckerCache(String cacheKey, long modificationStamp) {

// try the cache
Checker checker = sCheckerMap.getIfPresent(cacheKey);
Checker checker = CHECKERS.getIfPresent(cacheKey);

// if cache hit
if (checker != null) {

// compare modification times of the configs
final Long oldTime = sModifiedMap.get(cacheKey);
final Long oldTime = MODIFIED_TIME.get(cacheKey);
final Long newTime = Long.valueOf(modificationStamp);

// no match - remove checker from cache
if (oldTime == null || oldTime.compareTo(newTime) != 0) {
checker = null;
sCheckerMap.invalidate(cacheKey);
sModifiedMap.remove(cacheKey);
CHECKERS.invalidate(cacheKey);
MODIFIED_TIME.remove(cacheKey);
}
}
return checker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ public final class CheckConfigurationFactory {
/**
* List of known check configurations. Synchronized because of possible concurrend access.
*/
private static List<ICheckConfiguration> sConfigurations =
private static final List<ICheckConfiguration> CONFIGURATIONS =
Collections.synchronizedList(new ArrayList<ICheckConfiguration>());

/** The default check configuration. */
private static ICheckConfiguration sDefaultCheckConfig;
private static ICheckConfiguration defaultCheckConfig;

/** The default built-in check configuration. */
private static ICheckConfiguration sDefaultBuiltInConfig;
private static ICheckConfiguration defaultBuiltInConfig;

static {
refresh();
Expand All @@ -97,8 +97,8 @@ private CheckConfigurationFactory() {
* @return a new configuration working set
*/
public static ICheckConfigurationWorkingSet newWorkingSet() {
return new GlobalCheckConfigurationWorkingSet(sConfigurations,
getDefaultCheckConfiguration(), sDefaultBuiltInConfig);
return new GlobalCheckConfigurationWorkingSet(CONFIGURATIONS,
getDefaultCheckConfiguration(), defaultBuiltInConfig);
}

/**
Expand All @@ -110,7 +110,7 @@ public static ICheckConfigurationWorkingSet newWorkingSet() {
*/
public static ICheckConfiguration getByName(String name) {
ICheckConfiguration result = null;
for (ICheckConfiguration config : sConfigurations) {
for (ICheckConfiguration config : CONFIGURATIONS) {
if (config.getName().equals(name)) {
result = config;
break;
Expand All @@ -125,7 +125,7 @@ public static ICheckConfiguration getByName(String name) {
* @return A list containing all instances.
*/
public static List<ICheckConfiguration> getCheckConfigurations() {
return Collections.unmodifiableList(sConfigurations);
return Collections.unmodifiableList(CONFIGURATIONS);
}

/**
Expand All @@ -136,17 +136,17 @@ public static List<ICheckConfiguration> getCheckConfigurations() {
*/
public static ICheckConfiguration getDefaultCheckConfiguration() {
final ICheckConfiguration defaultConfig;
if (sDefaultCheckConfig != null) {
defaultConfig = sDefaultCheckConfig;
if (defaultCheckConfig != null) {
defaultConfig = defaultCheckConfig;
}
else if (sDefaultBuiltInConfig != null) {
defaultConfig = sDefaultBuiltInConfig;
else if (defaultBuiltInConfig != null) {
defaultConfig = defaultBuiltInConfig;
}
else if (sConfigurations.isEmpty()) {
else if (CONFIGURATIONS.isEmpty()) {
defaultConfig = null;
}
else {
defaultConfig = sConfigurations.get(0);
defaultConfig = CONFIGURATIONS.get(0);
}
return defaultConfig;
}
Expand All @@ -156,9 +156,9 @@ else if (sConfigurations.isEmpty()) {
*/
public static void refresh() {
try {
sDefaultCheckConfig = null;
sDefaultBuiltInConfig = null;
sConfigurations.clear();
defaultCheckConfig = null;
defaultBuiltInConfig = null;
CONFIGURATIONS.clear();
loadBuiltinConfigurations();
loadFromPersistence();

Expand Down Expand Up @@ -255,12 +255,12 @@ private static void loadFromPersistence() throws CheckstylePluginException {
final String defaultConfigName =
root.attributeValue(XMLTags.DEFAULT_CHECK_CONFIG_TAG);

sConfigurations.addAll(getGlobalCheckConfigurations(root));
CONFIGURATIONS.addAll(getGlobalCheckConfigurations(root));

for (ICheckConfiguration config : sConfigurations) {
if (config != sDefaultBuiltInConfig
for (ICheckConfiguration config : CONFIGURATIONS) {
if (config != defaultBuiltInConfig
&& config.getName().equals(defaultConfigName)) {
sDefaultCheckConfig = config;
defaultCheckConfig = config;
}
}
}
Expand Down Expand Up @@ -327,15 +327,15 @@ private static void loadBuiltinConfigurations() {
final ICheckConfiguration checkConfig = new CheckConfiguration(name, location,
description,
configType, true, props, additionalData);
sConfigurations.add(checkConfig);
CONFIGURATIONS.add(checkConfig);

if (defaultWeight > currentMaxDefaultWeight) {
currentMaxDefaultWeight = defaultWeight;
defaultBuiltInCheckConfig = checkConfig;
}
}

sDefaultBuiltInConfig = defaultBuiltInCheckConfig;
defaultBuiltInConfig = defaultBuiltInCheckConfig;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class RemoteConfigurationType extends AbstractConfigurationType {
private static final int TIMEOUT = 10000;

/** URLs that have failed with HTTP 401. */
private static Set<String> sFailedWith401URLs = new HashSet<>();
private static final Set<String> FAILED_WITH_401_URLS = new HashSet<>();

@Override
public CheckstyleConfigurationFile getCheckstyleConfiguration(
Expand Down Expand Up @@ -312,7 +312,7 @@ protected byte[] getBytesFromURLConnection(URLConnection connection) throws IOEx

if (connection instanceof HttpURLConnection) {

if (!sFailedWith401URLs.contains(connection.getURL().toString())) {
if (!FAILED_WITH_401_URLS.contains(connection.getURL().toString())) {

final HttpURLConnection httpConn = (HttpURLConnection) connection;
httpConn.setInstanceFollowRedirects(true);
Expand All @@ -326,7 +326,7 @@ protected byte[] getBytesFromURLConnection(URLConnection connection) throws IOEx
}

// add to 401ed URLs
sFailedWith401URLs.add(connection.getURL().toString());
FAILED_WITH_401_URLS.add(connection.getURL().toString());
throw new IOException(Messages.RemoteConfigurationType_msgUnAuthorized);
}
}
Expand Down Expand Up @@ -429,7 +429,7 @@ public static void storeCredentials(URL resolvedCheckConfigurationURL, String us
prefs.put(KEY_USERNAME, userName, false);
prefs.put(KEY_PASSWORD, password, true);

sFailedWith401URLs.remove(resolvedCheckConfigurationURL.toString());
FAILED_WITH_401_URLS.remove(resolvedCheckConfigurationURL.toString());
}
catch (CheckstylePluginException | StorageException ex) {
CheckstyleLog.log(ex);
Expand All @@ -446,7 +446,7 @@ public static void storeCredentials(URL resolvedCheckConfigurationURL, String us
*/
public static void removeCachedAuthInfo(URL resolvedCheckConfigurationURL)
throws CheckstylePluginException {
sFailedWith401URLs.remove(resolvedCheckConfigurationURL.toString());
FAILED_WITH_401_URLS.remove(resolvedCheckConfigurationURL.toString());

final String storagePath = getSecureStoragePath(resolvedCheckConfigurationURL);

Expand Down

This file was deleted.

Loading
Loading