Skip to content

Commit

Permalink
Merge pull request #25 from Yelp/24_fix_baseline_order
Browse files Browse the repository at this point in the history
[baseline output] Add sort_keys=True to json.dumps
  • Loading branch information
KevinHock authored Jun 14, 2018
2 parents c567c47 + e15d0a9 commit 567a981
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion detect_secrets/core/secrets_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,11 @@ def json(self):
return output

def __str__(self): # pragma: no cover
return json.dumps(self.json(), indent=2)
return json.dumps(
self.json(),
indent=2,
sort_keys=True
)

def __getitem__(self, key): # pragma: no cover
return self.data[key]
Expand Down
1 change: 1 addition & 0 deletions detect_secrets/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def main(argv=None):
args.scan
).format_for_baseline_output(),
indent=2,
sort_keys=True
)
)

Expand Down
1 change: 1 addition & 0 deletions detect_secrets/pre_commit_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def main(argv=None):
json.dumps(
baseline_collection.format_for_baseline_output(),
indent=2,
sort_keys=True
)
)

Expand Down
6 changes: 5 additions & 1 deletion tests/pre_commit_hook_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,8 @@ def _create_baseline():
},
}

return json.dumps(baseline, indent=2)
return json.dumps(
baseline,
indent=2,
sort_keys=True
)

0 comments on commit 567a981

Please sign in to comment.