[pmd] handle failure of decoding procedure ids as Java methods

Summary:
The code was pretty fragile, it's less fragile now. We should probably just
delete that and start outputting proper class/package info directly in the
report.json instead of reverse-engineering them.

Fixes #640

Reviewed By: jeremydubreil

Differential Revision: D4905973

fbshipit-source-id: 1590067
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent 93ec47a5f4
commit 06dfadecb7

@ -208,17 +208,23 @@ def _pmd_xml_of_issues(issues):
root.attrib['version'] = '5.4.1'
root.attrib['date'] = datetime.datetime.now().isoformat()
for issue in issues:
fully_qualifed_method_name = re.search('(.*)\(.*',
issue[JSON_INDEX_PROCEDURE_ID])
class_name = ''
package = ''
if fully_qualifed_method_name is not None:
# probably Java
info = fully_qualifed_method_name.groups()[0].split('.')
successful_java = False
if issue[JSON_INDEX_FILENAME].endswith('.java'):
fully_qualified_method_name = re.search(
'(.*)\(.*', issue[JSON_INDEX_PROCEDURE_ID])
if fully_qualified_method_name is not None:
# probably Java, let's try
try:
info = fully_qualified_method_name.groups()[0].split('.')
class_name = info[-2:-1][0]
method = info[-1]
package = '.'.join(info[0:-2])
else:
successful_java = True
except IndexError:
successful_java = False
if not successful_java:
class_name = ''
package = ''
method = issue[JSON_INDEX_PROCEDURE]
file_node = etree.Element('file')
file_node.attrib['name'] = issue[JSON_INDEX_FILENAME]

@ -10,7 +10,8 @@ TESTS_DIR = ../../..
ANALYZER = infer
CLANG_OPTIONS = -x c++ -std=c++11 -isystem$(ROOT_DIR) -c
INFER_OPTIONS = --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed
INFER_OPTIONS = --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) \
--no-failures-allowed --pmd-xml
INFERPRINT_OPTIONS = --issues-tests
SOURCES = \

Loading…
Cancel
Save