scc icon indicating copy to clipboard operation
scc copied to clipboard

JSON format is broken

Open eaigner opened this issue 1 year ago • 2 comments

Describe the bug

When supplied with the -f json flag, the output generates an array for the Files field instead of an int

[
    {
        "Name": "Swift",
        "Bytes": 2052746,
        "CodeBytes": 0,
        "Lines": 67684,
        "Code": 47337,
        "Comment": 7389,
        "Blank": 12958,
        "Complexity": 3132,
        "Count": 946,
        "WeightedComplexity": 0,
        "Files": []
    },

    etc...

To Reproduce

run scc -f json

Expected behavior

The files field should be of type Int not an empty array

Desktop (please complete the following information):

  • OS: macOS 12.5 (21G72)
  • Version [3.0.0]

eaigner avatar Aug 24 '22 14:08 eaigner

I just realized that the JSON outputs Count field is what probably should be the Files value.

It seems like a bug nevertheless, hovever keeping in mind that this format is best for machine consumption (at least I am using it that way), any change would probably break existing consumers.

eaigner avatar Aug 24 '22 14:08 eaigner

Yep Count is what you are looking for in this case.

I don't know if I would classify it as a bug, but even if it was its unlikely to change in order to ensure backwards compatibility.

boyter avatar Aug 25 '22 00:08 boyter

Going to close on the basic, that empty isnt a huge issue and I don't want to break backwards compatibility.

boyter avatar Dec 18 '23 00:12 boyter