Skip to content

recommend command fails when xml format is specified #811

@AntonProkopyev

Description

@AntonProkopyev

Aibolit fails when xml report is requested.

$ python -m aibolit recommend --folder test/integration/check --format=xml --full
Version 1.3.0 is available, but you are using 0.0.0
ignore: []
Traceback (most recent call last):
  ...
  File "/home/me/aibolit/aibolit/__main__.py", line 536, in _process_file_result
    if pattern.get('pattern_code'):
       ^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'get'

Test to reproduce the bug

diff --git a/test/recommend/test_recommend_pipeline.py b/test/recommend/test_recommend_pipeline.py
index c95986db..6e444249 100644
--- a/test/recommend/test_recommend_pipeline.py
+++ b/test/recommend/test_recommend_pipeline.py
@@ -156,6 +156,11 @@ class TestRecommendPipeline(TestCase):
         mock_cmd = self.__create_mock_cmd()
         create_xml_tree([], full_report=True, cmd=mock_cmd, exit_code=0)
 
+    def test_xml(self):
+        mock_input = self.__create_mock_input()
+        mock_cmd = self.__create_mock_cmd()
+        create_xml_tree(mock_input, cmd=mock_cmd, exit_code=2)
+
     def test_text_format(self):
         mock_input = self.__create_mock_input()
         new_mock = format_converter_for_pattern(mock_input)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions