Hi Tamar,
A few suggestions below.
>diff --git a/contrib/check_GNU_style_lib.py b/contrib/check_GNU_style_lib.py
>index
>>6dbe4b53559c63d2e0276d0ff88619cd2f7f8e06..ab21ed4607593668ab95f24715295a41ac7d8>a21
> 100755
>--- a/contrib/check_GNU_style_lib.py
>+++ b/contrib/check_GNU_style_lib.py
>@@ -29,6 +29,7 @@
> import sys
> import re
> import unittest
>+import json
> def import_pip3(*args):
> missing=[]
>@@ -317,6 +318,33 @@ def check_GNU_style_file(file, format):
> else:
> print('%d error(s) written to %s file.' % (len(errors), f))
> exit(1)
>+elif format == 'json':
>+fn = lambda x: x.error_message
>+i = 1
>+result = []
>+for (k, errors) in groupby(sorted(errors, key = fn), fn):
>+errors = list(errors)
>+entry = {}
>+entry['type'] = i
>+entry['msg'] = k
>+entry['count'] = len(errors)
>+i += 1
>+errlines = []
>+for e in errors:
>+locs = e.error_location ().split(':')
>+errlines.append({ "file": locs[0]
>+, "row": int(locs[1])
>+, "column": int(locs[2])
>+, "err": e.console_error })
>+entry['errors'] = errlines
>+result.append(entry)
>+
>+if len(errors) == 0:
>+exit(0)
>+else:
>+json_string = json.dumps(result)
>+print(json_string)
>+exit(1)
> else:
> assert False
Might be a good idea to rename "fn" -> "get_err", "i" -> "error_type_counter",
"k" -> "error_message", "errors" -> "grouped_errors" to make it easier to
understand.
You can also simplify "entry" construction like this:
entry = {
'type': error_type_counter,
'msg': error_message,
'count': len(grouped_errors)
}
BR,
- Vladimir Miloserdov