8

Landscape.io offers nice and good Python code tests and based on PEP 8, Pylint, McCabe, etc.

Some of my parser methods contain big switch blocks, so I would like to disable the McCabe test MC0001 for selected methods. How can I do this?

I found this syntax for PyLint:

for file in get_files():  # pylint:disable=redefined-builtin

Source: https://docs.landscape.io/suppressing.html

... but no syntax is shown for mccabe. Based on my Google research, it's possible to disable a McCabe rule for all files in a project, but this is not my goal. Here is a YAML file globally disabling MC0001:

mccabe:
  disable:
  - MC0001

Source: https://0x7df.wordpress.com/tag/mccabe/

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Paebbels
  • 15,573
  • 13
  • 70
  • 139
  • 3
    If you are using mccabe as a Flake8 plugin, you can disable it by the same means you disable Flake8 warnings: `# noqa: MC0001` on the respective line, see https://github.com/PyCQA/mccabe/tree/c2f5b386458cfda0aa4239f4d11b4e5e75027bda#plugin-for-flake8: "To silence violations reported by `mccabe`, place your `# noqa: C901` on the function definition line". Otherwise it's not possible (stated in the same section). – Sebastian Höffner Jun 25 '18 at 08:45
  • 1
    The link is broken: *"0x7df.wordpress.com is no longer available. The authors have deleted this site."* – Peter Mortensen Dec 21 '22 at 00:54
  • The docs.landscape.io link is also broken: *"Hmm. We’re having trouble finding that site. We can’t connect to the server at docs.landscape.io."* – Peter Mortensen Dec 31 '22 at 03:41
  • Firefox is not happy with the *landscape.io* link: *"Warning: Potential Security Risk Ahead. Firefox detected a potential security threat and did not continue to landscape.io. If you visit this site, attackers could try to steal information like your passwords, emails, or credit card details."* – Peter Mortensen Dec 31 '22 at 03:42
  • Landscape.io is a dead project. Please note, this question was asked 6 years ago ... The Internet is a living thing. Services come and go. – Paebbels Dec 31 '22 at 08:42

0 Answers0