Skip to content

Commit 98388be

Browse files
committed
Python: Remove special casing of hidden files
If it is necessary to exclude hidden files, then adding ``` paths-ignore: ['**/.*/**'] ``` to the relevant config file is recommended instead.
1 parent 61719cf commit 98388be

File tree

1 file changed

+8
-37
lines changed

1 file changed

+8
-37
lines changed

python/extractor/semmle/traverser.py

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -85,48 +85,19 @@ def _treewalk(self, path):
8585
if isdir(fullpath):
8686
if fullpath in self.exclude_paths:
8787
self.logger.debug("Ignoring %s (excluded)", fullpath)
88-
elif is_hidden(fullpath):
89-
self.logger.debug("Ignoring %s (hidden)", fullpath)
90-
else:
91-
empty = True
92-
for item in self._treewalk(fullpath):
93-
yield item
94-
empty = False
95-
if not empty:
96-
yield fullpath
88+
continue
89+
90+
empty = True
91+
for item in self._treewalk(fullpath):
92+
yield item
93+
empty = False
94+
if not empty:
95+
yield fullpath
9796
elif self.filter(fullpath):
9897
yield fullpath
9998
else:
10099
self.logger.debug("Ignoring %s (filter)", fullpath)
101100

102-
103-
if os.environ.get("CODEQL_EXTRACTOR_PYTHON_OPTION_SKIP_HIDDEN_DIRECTORIES", "false") == "false":
104-
105-
def is_hidden(path):
106-
return False
107-
108-
elif os.name== 'nt':
109-
import ctypes
110-
111-
def is_hidden(path):
112-
#Magical windows code
113-
try:
114-
attrs = ctypes.windll.kernel32.GetFileAttributesW(str(path))
115-
if attrs == -1:
116-
return False
117-
if attrs&2:
118-
return True
119-
except Exception:
120-
#Not sure what to log here, probably best to carry on.
121-
pass
122-
return os.path.basename(path).startswith(".")
123-
124-
else:
125-
126-
def is_hidden(path):
127-
return os.path.basename(path).startswith(".")
128-
129-
130101
def exclude_filter_from_options(options):
131102
if options.exclude_package:
132103
choices = '|'.join(mod.replace('.', r'\.') for mod in options.exclude_package)

0 commit comments

Comments
 (0)