Skip to content

Commit

Permalink
Fix flake issues
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu Rul <[email protected]>
  • Loading branch information
mathroule committed Jun 16, 2023
1 parent 42461b7 commit 0cfcac0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion yamllint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def run(argv=None):
sys.exit(-1)
results['stdin'] = problems

max_level = show_results(results, args_format=args.format, no_warn=args.no_warnings)
max_level = show_results(results, args_format=args.format,
no_warn=args.no_warnings)

if max_level == PROBLEM_LEVELS['error']:
return_code = 1
Expand Down
17 changes: 12 additions & 5 deletions yamllint/formatters/sarif.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def format_results(results, no_warn):
max_level = 0

sarif = {
'$schema': 'https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json',
'$schema': 'https://raw.githubusercontent.com/oasis-tcs/sarif-spec'
'/master/Schemata/sarif-schema-2.1.0.json',
'version': '2.1.0',
'runs': [
{
Expand Down Expand Up @@ -52,21 +53,27 @@ def format_results(results, no_warn):
else:
rule_index = max_rule_index
rules[problem.rule] = max_rule_index
sarif['runs'][0]['tool']['driver']['rules'].append(format_rule(problem))
sarif['runs'][0]['tool']['driver']['rules'].append(format_rule(
problem))
max_rule_index += 1

sarif['runs'][0]['results'].append(format_result(rule_index, problem, file))
sarif['runs'][0]['results'].append(format_result(rule_index,
problem, file))

print(json.dumps(sarif))

return max_level


def format_rule(problem):
uri = 'https://yamllint.readthedocs.io/en/v{}/rules.html#module-yamllint.rules.{}'.format(APP_VERSION, problem.rule)
uri = 'https://yamllint.readthedocs.io/en/v%s/rules.html#module-yamllint' \
'.rules.%s' % (APP_VERSION, problem.rule)

name = ''.join([word.capitalize() for word in problem.rule.split('-')])

return {
'id': problem.rule,
'name': ''.join([word.capitalize() for word in problem.rule.split('-')]),
'name': name,
'defaultConfiguration': {
'level': problem.level
},
Expand Down

0 comments on commit 0cfcac0

Please sign in to comment.