From f9ee73f1485503de74ee73b590301046ca534554 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 11 Mar 2017 16:55:34 +0000 Subject: [PATCH] RegexpOnFilename: Add a new rule to detect if there are any sync conflict files Fails if there there are any Syncthing or Dropbox sync conflicts on any *.java file. --- README.md | 17 +++++++++++++++++ builder/src/main/resources/application.yml | 10 ++++++++++ .../main/resources/rules/RegexpOnFilename.md | 15 +++++++++++++++ .../net/kemitix/checkstyle-1-layout.xml | 6 +++++- .../net/kemitix/checkstyle-2-naming.xml | 6 +++++- .../net/kemitix/checkstyle-3-javadoc.xml | 6 +++++- .../net/kemitix/checkstyle-4-tweaks.xml | 6 +++++- .../net/kemitix/checkstyle-5-complexity.xml | 6 +++++- 8 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 builder/src/main/resources/rules/RegexpOnFilename.md diff --git a/README.md b/README.md index 6b6028c..99a6525 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,7 @@ Rule|Level|Source|Enabled|Suppressable [Regexp](#regexp)|unspecified|checkstyle|| [RegexpHeader](#regexpheader)|unspecified|checkstyle|| [RegexpMultiline](#regexpmultiline)|unspecified|checkstyle|| +[RegexpOnFilename](#regexponfilename)|layout|checkstyle|Yes| [RegexpOnFilename](#regexponfilename)|unspecified|checkstyle|| [RegexpSingleline](#regexpsingleline)|unspecified|checkstyle|| [RegexpSinglelineJava](#regexpsinglelinejava)|unspecified|checkstyle|| @@ -274,6 +275,22 @@ The following is a list of each of the checks and the expectations each has on y Rules are listed in alphabetical order. +#### [RegexpOnFilename](http://checkstyle.sourceforge.net/config_regexp.html#RegexpOnFilename) + +Checks for the existence of forbidden java file names. + +File names are forbidden if they match the pattern `(.sync-conflict-| conflicted copy )`. + +N.B. only `*.java` files are checked. + +This check is intended to detect Syncthing and Dropbox conflict files. + +e.g. +```` +DataClass (Bob's conflicted copy 2017-03-11).java +DataClass.sync-conflict-20170311-1648.java +```` + #### [AbbreviationAsWordInName](http://checkstyle.sourceforge.net/config_naming.html#AbbreviationAsWordInName) Enforces proper `CamelCase` and avoids sequences of consecutive uppercase characters in identifiers. Does not apply to @Overridden methods. diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 674e39a..02ca4d6 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -12,6 +12,16 @@ template: readme-template: builder/src/main/resources/README-template.md readme-fragments: builder/src/main/resources/rules rules: + - + name: RegexpOnFilename + parent: CHECKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_regexp.html#RegexpOnFilename + properties: + fileNamePattern: "(.sync-conflict-| conflicted copy )" + match: true - name: AbbreviationAsWordInName parent: TREEWALKER diff --git a/builder/src/main/resources/rules/RegexpOnFilename.md b/builder/src/main/resources/rules/RegexpOnFilename.md new file mode 100644 index 0000000..5319e2c --- /dev/null +++ b/builder/src/main/resources/rules/RegexpOnFilename.md @@ -0,0 +1,15 @@ + +Checks for the existence of forbidden java file names. + +File names are forbidden if they match the pattern `(.sync-conflict-| conflicted copy )`. + +N.B. only `*.java` files are checked. + +This check is intended to detect Syncthing and Dropbox conflict files. + +e.g. +```` +DataClass (Bob's conflicted copy 2017-03-11).java +DataClass.sync-conflict-20170311-1648.java +```` + diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml index 72c0d46..c7c3f72 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml @@ -4,7 +4,11 @@ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> - + + + + + diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml index d27be47..040fe94 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml @@ -4,7 +4,11 @@ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> - + + + + + diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml index 1fe56af..811e021 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml @@ -4,7 +4,11 @@ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> - + + + + + diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml index cf4ce72..50b1a88 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml @@ -4,7 +4,11 @@ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> - + + + + + diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml index 44de9aa..b258137 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml @@ -4,7 +4,11 @@ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> - + + + + +