Skip to content

Conversation

@practicalswift
Copy link
Contributor

@practicalswift practicalswift commented Oct 2, 2018

Add Python dead code linter (vulture) to Travis.

Rationale for allowing dead code only after explicit opt-in (via --ignore-names):

  • Less is more :-)
  • Unused code is by definition "untested"
  • Unused code can be an indication of bugs/logical errors. By making the contributor aware of newly introduced unused code it gives him/her an opportunity to investigate if the unused code they introduce is malignant or benign :-)
  • Unused code is hard to spot for humans and is thus often missed during manual review
  • YAGNI

Based on #14312 to make linter job pass.

@practicalswift
Copy link
Contributor Author

practicalswift commented Oct 2, 2018

I've tested this linter over the set of all open mergeable pull requests.

A total of 196 pull requests were tested:

  • One true positive was found (and reported!)
  • Zero false positives were found

A precision score of 100 percent :-)

@practicalswift practicalswift force-pushed the lint-python-dead-code branch 2 times, most recently from 7d88eb5 to 6d3822d Compare October 2, 2018 11:51
Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my system it takes around 1 second so it's not a big deal.

I suggest closing #14312.

@practicalswift
Copy link
Contributor Author

@promag Thanks for reviewing. Good idea! Done.

@practicalswift
Copy link
Contributor Author

@MarcoFalke Updated. Please re-review :-)

maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Oct 4, 2018
ff94da7 tests: Make appveyor run with --usecli (practicalswift)
db01839 test: Add missing call to skip_if_no_cli() (practicalswift)

Pull request description:

  Add missing call to `skip_if_no_cli()` as suggested by @MarcoFalke in bitcoin#14365.

Tree-SHA512: b0a2ddfad0f81cc9544f63c4e490fb983d833a47c23522549d1200ea6a8a132b2cd4bf0d66b862ef3a548d8471128b80aea3525fb5dec65221e23f32a8d46746
@promag
Copy link
Contributor

promag commented Oct 4, 2018

Should explicitly set --min-confidence? Currently it's 60.

@practicalswift
Copy link
Contributor Author

@promag Judging from my testing of vulture over the set of the 196 mergeable open PR:s the default of 60 seems reasonable. Should we keep the default for now?

@promag
Copy link
Contributor

promag commented Oct 4, 2018

My suggestion is to add --min-confidence 60.

Also, from the vulture documentation:

We recommend using whitelists instead of --ignore-names or --ignore-decorators whenever possible

WDYT?

@practicalswift
Copy link
Contributor Author

@promag I've not added an explicit --min-confidence 60.

Regarding the white-list method: I'm afraid a whitelist replicating the current wildcard based method would be quite long. And perhaps burdensome to keep updated.

The trade-off looks like this:

    --ignore-names "argtypes,connection_lost,connection_made,converter,data_received,\
        daemon,errcheck,msg_generic,on_*,optionxform,restype,skip_if_no_cli"

Versus:

$ vulture --min-confidence 60 --make-whitelist $(git ls-files -- "*.py" ":(exclude)contrib/") | wc -l
110

Despite the recommendation I think --ignore-names might be the better option for us since we need the wildcard functionality.

@promag
Copy link
Contributor

promag commented Oct 4, 2018

@promag I've not added an explicit --min-confidence 60.

You have.

@practicalswift
Copy link
Contributor Author

@promag I've not added an explicit --min-confidence 60.

You have.

Oh, "not" should have been "now" :-D

@ken2812221
Copy link
Contributor

utACK c422cf2b50b08b489172de28f69083784c35a455

1 similar comment
@jb55
Copy link
Contributor

jb55 commented Oct 8, 2018 via email

@conscott
Copy link
Contributor

conscott commented Oct 12, 2018

utACk c422cf2b50b08b489172de28f69083784c35a455 - vulture is great!

@practicalswift
Copy link
Contributor Author

practicalswift commented Oct 16, 2018

Added a commit which pins the vulture version to avoid the possibility of having the build broken if a new vulture version being released.

Please re-review :-)

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 27, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #14505 (Make all single parameter constructors explicit (C++11) by practicalswift)
  • #13728 (Scripts and tools: Run the CI lint stage on mac by Empact)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@maflcko
Copy link
Member

maflcko commented Nov 7, 2018

Going to merge this since it had 3 utACKs and is probably not worth to wait for all re-ACKs.

@maflcko maflcko merged commit c82190c into bitcoin:master Nov 7, 2018
maflcko pushed a commit that referenced this pull request Nov 7, 2018
c82190c tests: Add Python dead code linter (vulture) (practicalswift)
590a57f tests: Remove unused testing code (practicalswift)

Pull request description:

  Add Python dead code linter (`vulture`) to Travis.

  Rationale for allowing dead code only after explicit opt-in (via `--ignore-names`):
  * Less is more :-)
  * Unused code is by definition "untested"
  * Unused code can be an indication of bugs/logical errors. By making the contributor aware of newly introduced unused code it gives him/her an opportunity to investigate if the unused code they introduce is malignant or benign :-)
  * Unused code is hard to spot for humans and is thus often missed during manual review
  * [YAGNI](https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it)

  Based on #14312 to make linter job pass.

Tree-SHA512: 4c581df7c34986e226e4ade479e0d3c549daf38f4a4dc4564b25564d63e773a1830ba55d1289c771b1fa325483e8855b82b56e61859fe8e4b7dfa54034b093b6
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 20, 2020
Summary:
Removal of dead python code

Partial backport of [[bitcoin/bitcoin#14365 | PR14365]]
Commit bitcoin/bitcoin@590a57f
Depends on D7981 (backported out of order)

Test Plan: `ninja && ninja check-functional`

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7987
@practicalswift practicalswift deleted the lint-python-dead-code branch April 10, 2021 19:36
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Aug 11, 2021
…Travis

c82190c tests: Add Python dead code linter (vulture) (practicalswift)
590a57f tests: Remove unused testing code (practicalswift)

Pull request description:

  Add Python dead code linter (`vulture`) to Travis.

  Rationale for allowing dead code only after explicit opt-in (via `--ignore-names`):
  * Less is more :-)
  * Unused code is by definition "untested"
  * Unused code can be an indication of bugs/logical errors. By making the contributor aware of newly introduced unused code it gives him/her an opportunity to investigate if the unused code they introduce is malignant or benign :-)
  * Unused code is hard to spot for humans and is thus often missed during manual review
  * [YAGNI](https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it)

  Based on bitcoin#14312 to make linter job pass.

Tree-SHA512: 4c581df7c34986e226e4ade479e0d3c549daf38f4a4dc4564b25564d63e773a1830ba55d1289c771b1fa325483e8855b82b56e61859fe8e4b7dfa54034b093b6
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Aug 12, 2021
…Travis

c82190c tests: Add Python dead code linter (vulture) (practicalswift)
590a57f tests: Remove unused testing code (practicalswift)

Pull request description:

  Add Python dead code linter (`vulture`) to Travis.

  Rationale for allowing dead code only after explicit opt-in (via `--ignore-names`):
  * Less is more :-)
  * Unused code is by definition "untested"
  * Unused code can be an indication of bugs/logical errors. By making the contributor aware of newly introduced unused code it gives him/her an opportunity to investigate if the unused code they introduce is malignant or benign :-)
  * Unused code is hard to spot for humans and is thus often missed during manual review
  * [YAGNI](https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it)

  Based on bitcoin#14312 to make linter job pass.

Tree-SHA512: 4c581df7c34986e226e4ade479e0d3c549daf38f4a4dc4564b25564d63e773a1830ba55d1289c771b1fa325483e8855b82b56e61859fe8e4b7dfa54034b093b6
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Sep 16, 2021
ff94da7 tests: Make appveyor run with --usecli (practicalswift)
db01839 test: Add missing call to skip_if_no_cli() (practicalswift)

Pull request description:

  Add missing call to `skip_if_no_cli()` as suggested by @MarcoFalke in bitcoin#14365.

Tree-SHA512: b0a2ddfad0f81cc9544f63c4e490fb983d833a47c23522549d1200ea6a8a132b2cd4bf0d66b862ef3a548d8471128b80aea3525fb5dec65221e23f32a8d46746
linuxsh2 pushed a commit to linuxsh2/dash that referenced this pull request Sep 16, 2021
ff94da7 tests: Make appveyor run with --usecli (practicalswift)
db01839 test: Add missing call to skip_if_no_cli() (practicalswift)

Pull request description:

  Add missing call to `skip_if_no_cli()` as suggested by @MarcoFalke in bitcoin#14365.

Tree-SHA512: b0a2ddfad0f81cc9544f63c4e490fb983d833a47c23522549d1200ea6a8a132b2cd4bf0d66b862ef3a548d8471128b80aea3525fb5dec65221e23f32a8d46746
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Sep 21, 2021
ff94da7 tests: Make appveyor run with --usecli (practicalswift)
db01839 test: Add missing call to skip_if_no_cli() (practicalswift)

Pull request description:

  Add missing call to `skip_if_no_cli()` as suggested by @MarcoFalke in bitcoin#14365.

Tree-SHA512: b0a2ddfad0f81cc9544f63c4e490fb983d833a47c23522549d1200ea6a8a132b2cd4bf0d66b862ef3a548d8471128b80aea3525fb5dec65221e23f32a8d46746
gades pushed a commit to cosanta/cosanta-core that referenced this pull request May 11, 2022
…Travis

c82190c tests: Add Python dead code linter (vulture) (practicalswift)
590a57f tests: Remove unused testing code (practicalswift)

Pull request description:

  Add Python dead code linter (`vulture`) to Travis.

  Rationale for allowing dead code only after explicit opt-in (via `--ignore-names`):
  * Less is more :-)
  * Unused code is by definition "untested"
  * Unused code can be an indication of bugs/logical errors. By making the contributor aware of newly introduced unused code it gives him/her an opportunity to investigate if the unused code they introduce is malignant or benign :-)
  * Unused code is hard to spot for humans and is thus often missed during manual review
  * [YAGNI](https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it)

  Based on bitcoin#14312 to make linter job pass.

Tree-SHA512: 4c581df7c34986e226e4ade479e0d3c549daf38f4a4dc4564b25564d63e773a1830ba55d1289c771b1fa325483e8855b82b56e61859fe8e4b7dfa54034b093b6
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants