Skip to content
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
8 changes: 4 additions & 4 deletions graal/backends/core/analyzers/scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def __analyze_scancode_cli(self, file_paths):
"""Add information about license using scancode-cli

:param file_paths: file paths (in case of scancode_cli for concurrent execution on files)
:returns result: dict of the results of the analysis
:returns result: list of the results of the analysis
"""
result = {'files': []}
result = []

try:
cmd_scancli = ['python3', self.exec_path]
Expand Down Expand Up @@ -107,7 +107,7 @@ def __analyze_scancode_cli(self, file_paths):

for output_json in outputs_json:
file_info = output_json[0]['files'][0]
result['files'].append(file_info)
result.append(file_info)

return result

Expand All @@ -117,7 +117,7 @@ def analyze(self, **kwargs):
:param file_path: file path (in case of scancode)
:param file_paths: file paths ( in case of scancode_cli for concurrent execution on files )

:returns result: dict of the results of the analysis
:returns result: the results of the analysis
"""
if self.cli:
result = self.__analyze_scancode_cli(kwargs['file_paths'])
Expand Down
4 changes: 2 additions & 2 deletions graal/backends/core/colic.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ def _analyze(self, commit):
if files_to_process:
local_paths = [path[1] for path in files_to_process]
analysis = self.analyzer.analyze(local_paths)
for i in range(len(analysis['files'])):
analysis['files'][i]['file_path'] = files_to_process[i][0]
for i in range(len(analysis)):
analysis[i]['file_path'] = files_to_process[i][0]

return analysis

Expand Down
4 changes: 2 additions & 2 deletions tests/test_colic.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def test_fetch_scancode_cli(self):
for commit in commits:
self.assertEqual(commit['backend_name'], 'CoLic')
self.assertEqual(commit['category'], CATEGORY_COLIC_SCANCODE_CLI)
self.assertEqual(commit['data']['analysis']['files'][0]['file_path'],
self.assertEqual(commit['data']['analysis'][0]['file_path'],
'perceval/backends/core/github.py')
self.assertTrue('Author' in commit['data'])
self.assertTrue('Commit' in commit['data'])
Expand Down Expand Up @@ -288,7 +288,7 @@ def test_analyze(self):
license_analyzer = LicenseAnalyzer(SCANCODE_CLI_PATH, kind=SCANCODE_CLI)
analysis = license_analyzer.analyze(file_paths)

self.assertIn('licenses', analysis['files'][0])
self.assertIn('licenses', analysis[0])


class TestCoLicCommand(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_analyze_scancode_cli(self):
kwargs = {'file_paths': [os.path.join(self.tmp_data_path, ANALYZER_TEST_FILE)]}
result = scancode_cli.analyze(**kwargs)

self.assertIn('licenses', result['files'][0])
self.assertIn('licenses', result[0])

def test_analyze_error(self):
"""Test whether an exception is thrown in case of error"""
Expand Down