Feature request:
Closed this issue · 8 comments
Exclude autogenerated files based on an included comment/string.
cloc allows --exclude-content="Code generated by sqlc. DO NOT EDIT."
Something similar would be great
I do like the PR, however I have to ask why the existing generated-markers
flag did not work for this?
You could have done if I am correct
scc --generated-markers package --no-gen
in this case it would ignore all Go files since they all contain the package
indeed trying it in scc itself,
$ scc --generated-markers package --no-gen -i go --no-cocomo --no-size
───────────────────────────────────────────────────────────────────────────────
Language Files Lines Blanks Comments Code Complexity
───────────────────────────────────────────────────────────────────────────────
───────────────────────────────────────────────────────────────────────────────
Total 0 0 0 0 0 0
───────────────────────────────────────────────────────────────────────────────
or if we want to mark the generated files,
$ scc --generated-markers package --gen -i go --no-cocomo --no-size
───────────────────────────────────────────────────────────────────────────────
Language Files Lines Blanks Comments Code Complexity
───────────────────────────────────────────────────────────────────────────────
Go (gen) 30 9617 1480 468 7669 1530
───────────────────────────────────────────────────────────────────────────────
Total 30 9617 1480 468 7669 1530
───────────────────────────────────────────────────────────────────────────────
In your case however,
scc --generated-markers "Code generated by sqlc. DO NOT EDIT." --no-gen
This would look for that comment in the file and exclude it. Although the existing do not edit should work in this case as well if I am not mistaken.
Now perhaps we could rework the PR to include the new strings you are looking for to switch this on? Currently its set to []string{"do not edit", "<auto-generated />"},
so we could just expand that out?
@ptman
Use scc --no-gen
can solve this issue. I tested with sqlc repo's examples and it works well. If this doesn't work for you, could you put a simple example that can reproduce the problem?
@boyter
I am not a big fan of adding features, especially when the existing things can meet the needs. And I have not found a scenario that must need "exclude-content". Simple is best. If you find "exclude-content" necessary, feel free to tell me and I'll rework on it. Otherwise I'd like to close the PR on next monday.
By the way, cloc's "exclude-content" and "--generated-markers" are different things. scc's "--generated-markers" only checks the first 1000 bytes, but cloc checks every line of files. "exclude-content" also accepts regular expressions.
@apocelipes My bad, I didn't realize you wrote it, has assumed it was @ptman .
I still liked the PR, hence was curious about if --no-gen
would be a solution rather then adding a new method to solve this before considering merge. There may have been a legit use case for it.
Yes, the choice to only check the first 1000 bytes was deliberate, since its rare these markers are not at the head of the file. Id be open to expanding that though if you deem it required. Moving it over to regex is something that could be considered as well.
Note I don't think we need an explicit match for this as the existing "do not edit" should cover this case. Looking for your response @ptman
Sorry, --no-gen works. I just somehow overlooked it.
In which case @apocelipes sorry about your work going to waste in this case, seems its not required.
In which case @apocelipes sorry about your work going to waste in this case, seems its not required.
That's all right. However, I think it would be better to add some common use cases as examples to README.md#Usage.
If you want to add that in let me know. Otherwise ill get around to doing it at some point.
If you want to add that in let me know. Otherwise ill get around to doing it at some point.
Ok, I have no plans to add these examples yet. You can add it.