From 2fa70c5e58ac67a190362f3683d30aded32ca822 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sat, 3 Aug 2019 22:41:00 +0700 Subject: [PATCH] JavaPMDBear: Use ExecutableRequirement Describe current executable requirements of pmd or run.sh. Related to https://github.com/coala/coala-bears/issues/2937 --- bears/java/JavaPMDBear.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bears/java/JavaPMDBear.py b/bears/java/JavaPMDBear.py index 4932c5a208..b34f13df90 100644 --- a/bears/java/JavaPMDBear.py +++ b/bears/java/JavaPMDBear.py @@ -1,5 +1,10 @@ from shutil import which +from dependency_management.requirements.AnyOneOfRequirements import ( + AnyOneOfRequirements) +from dependency_management.requirements.ExecutableRequirement import ( + ExecutableRequirement) + from coalib.bearlib.abstractions.Linter import linter from coalib.bearlib import deprecate_settings from coala_utils.param_conversion import negate @@ -17,6 +22,13 @@ class JavaPMDBear: """ LANGUAGES = {'Java'} + REQUIREMENTS = { + AnyOneOfRequirements( + [ExecutableRequirement('pmd'), + ExecutableRequirement('run.sh'), + ] + ), + } AUTHORS = {'The coala developers'} AUTHORS_EMAILS = {'coala-devel@googlegroups.com'} LICENSE = 'AGPL-3.0' @@ -25,9 +37,7 @@ class JavaPMDBear: @classmethod def check_prerequisites(cls): - if which('bash') is None: - return 'bash is not installed.' - elif which('pmd') is None and which('run.sh') is None: + if which('pmd') is None and which('run.sh') is None: return ('PMD is missing. Make sure to install it from ' '') else: