Skip to content

Commit

Permalink
Added message when a file is disabled due to a FileNotFoundException (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jshiell committed Jun 29, 2016
1 parent dd994fa commit 9de6eb7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ This code is released under a BSD licence, as specified in the accompanying LICE

## Version History

* **4.29.2** Fixed: If the rules file for a configuration is deleted, we continue to show errors. It will now be deactivated (#240). Thanks to Victor Alenkov.
* **4.29.1** Fixed: Default property values should now be applied (#237).
* **4.29.0** New: Updated to CheckStyle 6.19.
* **4.29.0** Fixed: Optional suppression files should no longer generate errors (#231).
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ intellij {
}

sourceCompatibility = 1.8
version = '4.29.1'
version = '4.29.2'

task wrapper(type: Wrapper) {
gradleVersion = '2.13'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@

import static java.util.Collections.singletonList;
import static java.util.Optional.ofNullable;
import static org.infernus.idea.checkstyle.CheckStyleBundle.message;
import static org.infernus.idea.checkstyle.util.Async.asyncResultOf;
import static org.infernus.idea.checkstyle.util.Notifications.showWarning;

public class CheckStyleInspection extends LocalInspectionTool {

Expand Down Expand Up @@ -97,10 +99,11 @@ public List<Problem> inspectFile(@NotNull final PsiFile psiFile,
return NO_PROBLEMS_FOUND;

} catch (CheckStylePluginException e) {
blacklist(configurationLocation);
LOG.error("CheckStyle threw an exception when scanning: " + psiFile.getName(), e);
if (e.getCause() instanceof FileNotFoundException){
plugin.getConfiguration().setActiveConfiguration(null);
if (e.getCause() != null && e.getCause() instanceof FileNotFoundException) {
disableActiveConfiguration(plugin, manager.getProject());
} else {
blacklist(configurationLocation);
}
return NO_PROBLEMS_FOUND;

Expand All @@ -113,6 +116,11 @@ public List<Problem> inspectFile(@NotNull final PsiFile psiFile,
}
}

private void disableActiveConfiguration(final CheckStylePlugin plugin, final Project project) {
plugin.getConfiguration().setActiveConfiguration(null);
showWarning(project, message("checkstyle.configuration-disabled.error"));
}

private void blacklist(final ConfigurationLocation configurationLocation) {
if (configurationLocation != null) {
configurationLocation.blacklist();
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</p>
]]>
</description>
<version>4.29.1</version>
<version>4.29.2</version>
<idea-version since-build="141.178"/>
<vendor url="https://infernus.org/" email="james@infernus.org">James Shiell</vendor>

Expand All @@ -19,6 +19,7 @@
<change-notes>
<![CDATA[
<ul>
<li>4.29.2: Fixed: If the rules file for a configuration is deleted, we continue to show errors. It will now be deactivated (#240). Thanks to Victor Alenkov.</li>
<li>4.29.1: Fixed: Default property values should now be applied (#237).</li>
<li>4.29.0: New: Updated to CheckStyle 6.19.</li>
<li>4.29.0: Fixed: Optional suppression files should no longer generate errors (#231).</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ checkstyle.not-found.RegexpHeader=<html>The Checkstyle regexp header file<br>was
checkstyle.not-found.ImportControl=<html>The Checkstyle import control file<br>was not found and will be ignored</html>
checkstyle.not-found.Header=<html>The Checkstyle header file<br>was not found and will be ignored</html>
checkstyle.file-not-found=<html>The Checkstyle rules file could not be read</html>
checkstyle.configuration-disabled.error=<html>The current Checkstyle configuration has been disabled due to an error.</html>
checkstyle.checker-failed=<html><b>The Checkstyle rules file could not be loaded.</b><br>{0}<br>The file has been blacklisted for 60s.</html>
checkstyle.could-not-read-properties=<html>Properties could not be read from the Checkstyle configuration file</html>
checkstyle.double-checked-locking=<html>The Checkstyle configuration file is not compatible with Checkstyle 5.6 or above.<br>Please remove the DoubleCheckingLocking check.</html>
Expand Down

0 comments on commit 9de6eb7

Please sign in to comment.