-
Notifications
You must be signed in to change notification settings - Fork 36.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-add dead code detection #21096
Re-add dead code detection #21096
Conversation
meh, turns out clicked the wrong button, and now I can't mark it as Draft anymore... modified the title instead |
Please squash your commits according to https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits |
@MarcoFalke done |
Seems like at diff --git a/test/functional/test_framework/key.py b/test/functional/test_framework/key.py
index e0cbab45c..d0f3472e9 100644
--- a/test/functional/test_framework/key.py
+++ b/test/functional/test_framework/key.py
@@ -14,6 +14,10 @@ import unittest
from .util import modinv
+import nonsense
+
def TaggedHash(tag, data):
ss = hashlib.sha256(tag.encode('utf-8')).digest()
ss += ss bitcoin/test/functional/test_framework/key.py:17: unused import 'nonsense' (90% confidence) or bitcoin/test/functional/test_framework/key.py:23: unused function 'xor_bytes' (60% confidence) Looking at the vulture source this makes sense, because the default confidence for basically all checks is 60. |
c9095b7 test: remove unnecessary assignment in bdb (Bruno Garcia) Pull request description: This PR removes the unnecessary assignment to page_info['entries'] on line 54 since there is another assignment for it in line 59. I think a lint (bitcoin#21096) would detect cases like this one. ACKs for top commit: achow101: ACK c9095b7 theStack: Code Review ACK c9095b7 Tree-SHA512: 23377077c015b04361fd416b41bf6806ad0bdd4d264be6760f0fd3bc88d694d2cd52cae250519925c5d3b3c70715772714c3863f8fa181a2eb4883204ccdbf9d
c9095b7 test: remove unnecessary assignment in bdb (Bruno Garcia) Pull request description: This PR removes the unnecessary assignment to page_info['entries'] on line 54 since there is another assignment for it in line 59. I think a lint (bitcoin#21096) would detect cases like this one. ACKs for top commit: achow101: ACK c9095b7 theStack: Code Review ACK c9095b7 Tree-SHA512: 23377077c015b04361fd416b41bf6806ad0bdd4d264be6760f0fd3bc88d694d2cd52cae250519925c5d3b3c70715772714c3863f8fa181a2eb4883204ccdbf9d
|
@laanwj I'm not going to spend too much time arguing, but the rationale for #16961 was to avoid false positives. |
Concept ACK If simply specifying @laanwj, is your NACK made assuming that |
Okay retracted the NACK if everyone else wants this it's okay with me I just would really prefer if it doesn't come up as issue again. |
test/lint/lint-python-dead-code.sh
Outdated
# Any value below 100 introduces the risk of false positives, which would create an unacceptable maintenance burden. | ||
if ! vulture \ | ||
--min-confidence 100 \ | ||
$(git rev-parse --show-toplevel); then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be $(vulture --min-confidence 100 -- $(git ls-files -- "*.py"))
instead to make sure only files in the repo are checked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be changed if people think that's better. The rev-parse
version is what the previous incarnation of the linter had. I was thinking maybe you want to run the linter against a new file before you git add
it?
AFAICT, vulture automatically filters by file extension (https://github.com/jendrikseipp/vulture/blob/master/vulture/config.py#L105), so *.py
should be implicit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think this is a serious issue but, ostensibly a developer could, unwisely, keep their own .py
scripts inside the repo directory, which would make no sense to check here, so i think ls-files
to only check the committed ones makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, changed to ls-files
as requested
ACK 3f8776a |
Tested ACK by reintroducing the bug, didn't review:
|
3f8776a Re-add dead code detection (flack) Pull request description: This re-adds unreachable code detection for Python based on `vulture`. Effectively, this reverts f4beb49. The difference to the previous version is that this runs with the `--min-confidence 100` setting. From https://pypi.org/project/vulture/: > Use `--min-confidence 100` to only report code that is guaranteed to be unused within the analyzed files. So this should avoid the previous issues where static analysis had wrong positives due to the dynamic nature of Python code by only reporting things that are unambiguous (such as code after a `return` statement). As such, there is not suppressions list. My motivation was mainly bitcoin#21081 which would have been caught by this (as can be seen by the CI run failing). This is still marked as draft because bitcoin#21081 is needed to get the linter to pass. Also, there is a second problem that this found (see https://github.com/bitcoin/bitcoin/pull/19509/files#r571454691). From what I can tell, this is a spurious type comment that could just be removed (or if that line has no side effects it could also be deleted altogether?). I could add a commit here to fix it, but I wanted to see if there is interest in having this linter again in the first place ACKs for top commit: practicalswift: ACK 3f8776a Tree-SHA512: 52314ad4f627d969de1eb15375ca677ed86a2e816fe773756a1ce22421214ba407b5a09a4bf701a3aab1a10c7b336f548e4cef3327edf154acba55e987db21f6
3f8776a Re-add dead code detection (flack) Pull request description: This re-adds unreachable code detection for Python based on `vulture`. Effectively, this reverts f4beb49. The difference to the previous version is that this runs with the `--min-confidence 100` setting. From https://pypi.org/project/vulture/: > Use `--min-confidence 100` to only report code that is guaranteed to be unused within the analyzed files. So this should avoid the previous issues where static analysis had wrong positives due to the dynamic nature of Python code by only reporting things that are unambiguous (such as code after a `return` statement). As such, there is not suppressions list. My motivation was mainly bitcoin#21081 which would have been caught by this (as can be seen by the CI run failing). This is still marked as draft because bitcoin#21081 is needed to get the linter to pass. Also, there is a second problem that this found (see https://github.com/bitcoin/bitcoin/pull/19509/files#r571454691). From what I can tell, this is a spurious type comment that could just be removed (or if that line has no side effects it could also be deleted altogether?). I could add a commit here to fix it, but I wanted to see if there is interest in having this linter again in the first place ACKs for top commit: practicalswift: ACK 3f8776a Tree-SHA512: 52314ad4f627d969de1eb15375ca677ed86a2e816fe773756a1ce22421214ba407b5a09a4bf701a3aab1a10c7b336f548e4cef3327edf154acba55e987db21f6
3f8776a Re-add dead code detection (flack) Pull request description: This re-adds unreachable code detection for Python based on `vulture`. Effectively, this reverts f4beb49. The difference to the previous version is that this runs with the `--min-confidence 100` setting. From https://pypi.org/project/vulture/: > Use `--min-confidence 100` to only report code that is guaranteed to be unused within the analyzed files. So this should avoid the previous issues where static analysis had wrong positives due to the dynamic nature of Python code by only reporting things that are unambiguous (such as code after a `return` statement). As such, there is not suppressions list. My motivation was mainly bitcoin#21081 which would have been caught by this (as can be seen by the CI run failing). This is still marked as draft because bitcoin#21081 is needed to get the linter to pass. Also, there is a second problem that this found (see https://github.com/bitcoin/bitcoin/pull/19509/files#r571454691). From what I can tell, this is a spurious type comment that could just be removed (or if that line has no side effects it could also be deleted altogether?). I could add a commit here to fix it, but I wanted to see if there is interest in having this linter again in the first place ACKs for top commit: practicalswift: ACK 3f8776a Tree-SHA512: 52314ad4f627d969de1eb15375ca677ed86a2e816fe773756a1ce22421214ba407b5a09a4bf701a3aab1a10c7b336f548e4cef3327edf154acba55e987db21f6
3f8776a Re-add dead code detection (flack) Pull request description: This re-adds unreachable code detection for Python based on `vulture`. Effectively, this reverts f4beb49. The difference to the previous version is that this runs with the `--min-confidence 100` setting. From https://pypi.org/project/vulture/: > Use `--min-confidence 100` to only report code that is guaranteed to be unused within the analyzed files. So this should avoid the previous issues where static analysis had wrong positives due to the dynamic nature of Python code by only reporting things that are unambiguous (such as code after a `return` statement). As such, there is not suppressions list. My motivation was mainly bitcoin#21081 which would have been caught by this (as can be seen by the CI run failing). This is still marked as draft because bitcoin#21081 is needed to get the linter to pass. Also, there is a second problem that this found (see https://github.com/bitcoin/bitcoin/pull/19509/files#r571454691). From what I can tell, this is a spurious type comment that could just be removed (or if that line has no side effects it could also be deleted altogether?). I could add a commit here to fix it, but I wanted to see if there is interest in having this linter again in the first place ACKs for top commit: practicalswift: ACK 3f8776a Tree-SHA512: 52314ad4f627d969de1eb15375ca677ed86a2e816fe773756a1ce22421214ba407b5a09a4bf701a3aab1a10c7b336f548e4cef3327edf154acba55e987db21f6
3f8776a Re-add dead code detection (flack) Pull request description: This re-adds unreachable code detection for Python based on `vulture`. Effectively, this reverts f4beb49. The difference to the previous version is that this runs with the `--min-confidence 100` setting. From https://pypi.org/project/vulture/: > Use `--min-confidence 100` to only report code that is guaranteed to be unused within the analyzed files. So this should avoid the previous issues where static analysis had wrong positives due to the dynamic nature of Python code by only reporting things that are unambiguous (such as code after a `return` statement). As such, there is not suppressions list. My motivation was mainly bitcoin#21081 which would have been caught by this (as can be seen by the CI run failing). This is still marked as draft because bitcoin#21081 is needed to get the linter to pass. Also, there is a second problem that this found (see https://github.com/bitcoin/bitcoin/pull/19509/files#r571454691). From what I can tell, this is a spurious type comment that could just be removed (or if that line has no side effects it could also be deleted altogether?). I could add a commit here to fix it, but I wanted to see if there is interest in having this linter again in the first place ACKs for top commit: practicalswift: ACK 3f8776a Tree-SHA512: 52314ad4f627d969de1eb15375ca677ed86a2e816fe773756a1ce22421214ba407b5a09a4bf701a3aab1a10c7b336f548e4cef3327edf154acba55e987db21f6
3f8776a Re-add dead code detection (flack) Pull request description: This re-adds unreachable code detection for Python based on `vulture`. Effectively, this reverts f4beb49. The difference to the previous version is that this runs with the `--min-confidence 100` setting. From https://pypi.org/project/vulture/: > Use `--min-confidence 100` to only report code that is guaranteed to be unused within the analyzed files. So this should avoid the previous issues where static analysis had wrong positives due to the dynamic nature of Python code by only reporting things that are unambiguous (such as code after a `return` statement). As such, there is not suppressions list. My motivation was mainly bitcoin#21081 which would have been caught by this (as can be seen by the CI run failing). This is still marked as draft because bitcoin#21081 is needed to get the linter to pass. Also, there is a second problem that this found (see https://github.com/bitcoin/bitcoin/pull/19509/files#r571454691). From what I can tell, this is a spurious type comment that could just be removed (or if that line has no side effects it could also be deleted altogether?). I could add a commit here to fix it, but I wanted to see if there is interest in having this linter again in the first place ACKs for top commit: practicalswift: ACK 3f8776a Tree-SHA512: 52314ad4f627d969de1eb15375ca677ed86a2e816fe773756a1ce22421214ba407b5a09a4bf701a3aab1a10c7b336f548e4cef3327edf154acba55e987db21f6
3f8776a Re-add dead code detection (flack) Pull request description: This re-adds unreachable code detection for Python based on `vulture`. Effectively, this reverts f4beb49. The difference to the previous version is that this runs with the `--min-confidence 100` setting. From https://pypi.org/project/vulture/: > Use `--min-confidence 100` to only report code that is guaranteed to be unused within the analyzed files. So this should avoid the previous issues where static analysis had wrong positives due to the dynamic nature of Python code by only reporting things that are unambiguous (such as code after a `return` statement). As such, there is not suppressions list. My motivation was mainly bitcoin#21081 which would have been caught by this (as can be seen by the CI run failing). This is still marked as draft because bitcoin#21081 is needed to get the linter to pass. Also, there is a second problem that this found (see https://github.com/bitcoin/bitcoin/pull/19509/files#r571454691). From what I can tell, this is a spurious type comment that could just be removed (or if that line has no side effects it could also be deleted altogether?). I could add a commit here to fix it, but I wanted to see if there is interest in having this linter again in the first place ACKs for top commit: practicalswift: ACK 3f8776a Tree-SHA512: 52314ad4f627d969de1eb15375ca677ed86a2e816fe773756a1ce22421214ba407b5a09a4bf701a3aab1a10c7b336f548e4cef3327edf154acba55e987db21f6
This re-adds unreachable code detection for Python based on
vulture
.Effectively, this reverts f4beb49. The difference to the previous version is that this runs with the
--min-confidence 100
setting. From https://pypi.org/project/vulture/:So this should avoid the previous issues where static analysis had wrong positives due to the dynamic nature of Python code by only reporting things that are unambiguous (such as code after a
return
statement). As such, there is not suppressions list.My motivation was mainly #21081 which would have been caught by this (as can be seen by the CI run failing). This is still marked as draft because #21081 is needed to get the linter to pass. Also, there is a second problem that this found (see https://github.com/bitcoin/bitcoin/pull/19509/files#r571454691). From what I can tell, this is a spurious type comment that could just be removed (or if that line has no side effects it could also be deleted altogether?). I could add a commit here to fix it, but I wanted to see if there is interest in having this linter again in the first place