Skip to content

Commit

Permalink
fix celt json stats when there are no errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlopez-rod committed Oct 7, 2021
1 parent 90ad6d5 commit 669bc54
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/python/m/ci/celt/core/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,15 @@ def project_stats_json(
],
key=cmp_to_key(_compare_rule_items),
)
buffer.extend([
f' "{rule_id}": {rule.found},'
for rule_id, rule in key_rule[:-1]
])
rule_id, rule = key_rule[-1]
buffer.append(f' "{rule_id}": {rule.found}')

if key_rule:
buffer.extend([
f' "{rule_id}": {rule.found},'
for rule_id, rule in key_rule[:-1]
])
rule_id, rule = key_rule[-1]
buffer.append(f' "{rule_id}": {rule.found}')

buffer.extend([
' }',
'}',
Expand Down
10 changes: 10 additions & 0 deletions packages/python/tests/ci/celt/test_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ def test_eslint_no_errors(self):
assert_str_has(eslint.to_str(project), [
'no errors found'
])
# test json stats
json_stats = eslint.stats_json(project)
expected = """
{
"allowedEslintRules": {
}
}
"""
self.assertEqual(json_stats, inspect.cleandoc(expected))


def test_eslint_no_errors_reduce(self):
eslint = _post_processor('eslint')
Expand Down

0 comments on commit 669bc54

Please sign in to comment.