Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup and give better debug output for exclude patterns in findbugs and errorprone #4408

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
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def prepare(cls, options, round_manager):

@memoized_property
def _exclude_patterns(self):
return "(" + ")|(".join(self.get_options().exclude_patterns) + ")"
return [re.compile(x) for x in set(self.get_options().exclude_patterns or [])]

def _is_errorprone_target(self, target):
if not target.has_sources(self._JAVA_SOURCE_EXTENSION):
Expand All @@ -67,9 +67,11 @@ def _is_errorprone_target(self, target):
if target.is_synthetic:
self.context.log.debug('Skipping [{}] because it is a synthetic target'.format(target.address.spec))
return False
if self.get_options().exclude_patterns and re.match(self._exclude_patterns, target.address.spec):
self.context.log.debug('Skipping [{}] because it matches exclude pattern'.format(target.address.spec))
return False
for pattern in self._exclude_patterns:
if pattern.search(target.address.spec):
self.context.log.debug(
"Skipping [{}] because it matches exclude pattern '{}'".format(target.address.spec, pattern.pattern))
return False
return True

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def register_options(cls, register):
],
main=cls._FINDBUGS_MAIN,
custom_rules=[
Shader.exclude_package('edu.umd.cs.findbugs',
recursive=True),
Shader.exclude_package('edu.umd.cs.findbugs', recursive=True),
])

@classmethod
Expand All @@ -83,7 +82,7 @@ def cache_target_dirs(self):

@memoized_property
def _exclude_patterns(self):
return "(" + ")|(".join(self.get_options().exclude_patterns) + ")"
return [re.compile(x) for x in set(self.get_options().exclude_patterns or [])]

def _is_findbugs_target(self, target):
if not isinstance(target, (JavaLibrary, JUnitTests)):
Expand All @@ -92,9 +91,11 @@ def _is_findbugs_target(self, target):
if target.is_synthetic:
self.context.log.debug('Skipping [{}] because it is a synthetic target'.format(target.address.spec))
return False
if self.get_options().exclude_patterns and re.match(self._exclude_patterns, target.address.spec):
self.context.log.debug('Skipping [{}] because it matches exclude pattern'.format(target.address.spec))
return False
for pattern in self._exclude_patterns:
if pattern.search(target.address.spec):
self.context.log.debug(
"Skipping [{}] because it matches exclude pattern '{}'".format(target.address.spec, pattern.pattern))
return False
return True

def execute(self):
Expand Down