Rule for making @threads
not recommended
#1
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to this blogpost,
Threads.@threads
should not be used without:static
, or at all, preferring working directly with tasks usingThreads.@spawn
. I added a rule that searches for uses ofThreads.@threads
, but not forThreads.@threads :static
.When running
semgrep -c
on the.yml
and.jl
files, there are three matches:Lines 6-7 are matched two times. This is because of the
pattern-either
rule. This rule would not be necessary if Semgrep would support matching wildcard imports (such asusing Threads
), making@threads
be recognisable asThreads.@threads
and removing the need for checking both patterns. I understand from @brandonspark that they are working on making this possible.Also, I don't understand why the
end
line won't match as well (why, for example, doesn't the rule match lines 6-8 instead of just 6-7). But I don't think that's a big problem.