File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change 28
28
import xml .dom .minidom
29
29
import gitlint .git as git
30
30
31
+ def _FindFoldersContaining (root , wanted ):
32
+ """Searches recursively from root to find directories that has a file with
33
+ the given name.
34
+
35
+ Args:
36
+ root: Root folder to start the search from.
37
+ wanted: The filename that we are looking for.
38
+
39
+ Returns:
40
+ List of folders that has a file with the given name
41
+ """
42
+
43
+ if os .path .islink (root ):
44
+ return []
45
+ result = []
46
+ for fileName in os .listdir (root ):
47
+ filePath = os .path .join (root , fileName )
48
+ if os .path .isdir (filePath ):
49
+ subResult = _FindFoldersContaining (filePath , wanted )
50
+ result .extend (subResult )
51
+ else :
52
+ if fileName == wanted :
53
+ result .append (root )
54
+ return result
31
55
32
56
MAIN_DIRECTORY = os .path .normpath (os .path .dirname (__file__ ))
33
57
CHECKSTYLE_JAR = os .path .join (MAIN_DIRECTORY , 'checkstyle.jar' )
37
61
SKIPPED_RULES_FOR_TEST_FILES = ['com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck' ,
38
62
'com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck' ]
39
63
SUBPATH_FOR_TEST_FILES = ['/tests/' , '/test/' ]
40
- SUBPATH_FOR_TEST_DATA_FILES = ['src/tests/test-data/' ]
64
+ SUBPATH_FOR_TEST_DATA_FILES = _FindFoldersContaining (os .path .dirname (os .getcwd ()),
65
+ "IGNORE_CHECKSTYLE" )
41
66
ERROR_UNCOMMITTED = 'You need to commit all modified files before running Checkstyle\n '
42
67
ERROR_UNTRACKED = 'You have untracked java files that are not being checked:\n '
43
68
You can’t perform that action at this time.
0 commit comments