传送门

python官方代码扫描工具

Flake8 是由Python官方发布的一款辅助检测Python代码是否规范的工具,flake8是下面三个工具的封装:

  1. PyFlakes
  2. Pep8
  3. NedBatchelder’s McCabe script

概要

flake8 [options] [<path> <path> ...]flake8 --help

选项

$ flake8 --help
Usage: flake8 [options] file file ...Options:--version             show program s version number and exit-h, --help            show this help message and exit-v, --verbose         Print more information about what is happening inflake8. This option is repeatable and will increaseverbosity each time it is repeated.-q, --quiet           Report only file names, or nothing. This option isrepeatable.--count               Print total number of errors and warnings to standarderror and set the exit code to 1 if total is notempty.--diff                Report changes only within line number ranges in theunified diff provided on standard in by the user.--exclude=patterns    Comma-separated list of files or directories toexclude. (Default:.svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.eggs,*.egg)--filename=patterns   Only check for filenames matching the patterns in thiscomma-separated list. (Default: *.py)--stdin-display-name=STDIN_DISPLAY_NAMEThe name used when reporting errors from code passedvia stdin. This is useful for editors piping the filecontents to flake8. (Default: stdin)--format=format       Format errors according to the chosen formatter.--hang-closing        Hang closing bracket instead of matching indentationof opening bracket's line.--ignore=errors       Comma-separated list of errors and warnings to ignore(or skip). For example, ``--ignore=E4,E51,W234``.(Default: E121,E123,E126,E226,E24,E704,W503,W504)--extend-ignore=errorsComma-separated list of errors and warnings to add tothe list of ignored ones. For example, ``--extend-ignore=E4,E51,W234``.--per-file-ignores=PER_FILE_IGNORESA pairing of filenames and violation codes thatdefines which violations to ignore in a particularfile. The filenames can be specified in a mannersimilar to the ``--exclude`` option and the violationswork similarly to the ``--ignore`` and ``--select``options.--max-line-length=n   Maximum allowed line length for the entirety of thisrun. (Default: 79)--max-doc-length=n    Maximum allowed doc line length for the entirety ofthis run. (Default: none)--select=errors       Comma-separated list of errors and warnings to enable.For example, ``--select=E4,E51,W234``. (Default:E,F,W,C90)--disable-noqa        Disable the effect of "# noqa". This will reporterrors on lines with "# noqa" at the end.--show-source         Show the source generate each error or warning.--statistics          Count errors and warnings.--enable-extensions=ENABLE_EXTENSIONSEnable plugins and extensions that are otherwisedisabled by default--exit-zero           Exit with status code "0" even if there are errors.--install-hook=INSTALL_HOOKInstall a hook that is run prior to a commit for thesupported version control system.-j JOBS, --jobs=JOBS  Number of subprocesses to use to run checks inparallel. This is ignored on Windows. The default,"auto", will auto-detect the number of processorsavailable to use. (Default: auto)--output-file=OUTPUT_FILERedirect report to a file.--tee                 Write to stdout and output-file.--append-config=APPEND_CONFIGProvide extra config files to parse in addition to thefiles found by Flake8 by default. These files are thelast ones read and so they take the highest precedencewhen multiple files provide the same option.--config=CONFIG       Path to the config file that will be the authoritativeconfig source. This will cause Flake8 to ignore allother configuration files.--isolated            Ignore all configuration files.--benchmark           Print benchmark information about this run of Flake8--bug-report          Print information necessary when preparing a bugreport--builtins=BUILTINS   define more built-ins, comma separated--doctests            check syntax of the doctests--include-in-doctest=INCLUDE_IN_DOCTESTRun doctests only on these files--exclude-from-doctest=EXCLUDE_FROM_DOCTESTSkip these files when running doctests--max-complexity=MAX_COMPLEXITYMcCabe complexity thresholdInstalled plugins: mccabe: 0.6.1, pycodestyle: 2.5.0, pyflakes: 2.1.1

例子

只需对当前目录运行flake8:

flake8
flake8 .

针对特定路径运行flake8:

flake8 path/to/file.py

忽略来自flake8的违规行为:

flake8 --ignore E101
flake8 --ignore E1,E202

仅报告某些违规行为:

flake8 --select E101
flake8 --select E2,E742

仅分析差异:

git diff -U0 | flake8 --diff -

生成错误报告的信息:

flake8 --bug-report

【解锁】flake8——python官方代码扫描工具相关推荐

  1. GitHub 官方代码扫描工具上线!

    点击上方 Java后端,选择 设为星标 优质项目,及时送达 作者:蛋酱:本文经机器之心(微信公众号:almosthuman2014)授权转载,禁止二次转载. 在 GitHub 发布项目之前,你可以用免 ...

  2. GitHub官方代码扫描工具上线,免费查找代码漏洞 !

    本文经机器之心(微信公众号:almosthuman2014)授权转载,禁止二次转载 作者:蛋酱 机器之心整理 在 GitHub 发布项目之前,你可以用免费的官方代码扫描程序来检查 Bug 了. 编程很 ...

  3. 静态代码扫描工具(多种)简要入门介绍-SonarQube社区版-免费、TscanCode工具、PMD工具、flake8工具

    SonarQube社区版-免费 适用语言:Java, C#, JavaScript, TypeScript, CloudFormation, Terraform, Kotlin, Ruby, Go, ...

  4. Python静态代码检查工具Flake8

    简介 Flake8 是由Python官方发布的一款辅助检测Python代码是否规范的工具,相对于目前热度比较高的Pylint来说,Flake8检查规则灵活,支持集成额外插件,扩展性强.Flake8是对 ...

  5. Android Studio 工具:Lint 代码扫描工具(含自定义lint)

    什么是 Lint Android Lint 是 SDK Tools 16(ADT 16)开始引入的一个代码扫描工具,通过对代码进行静态分析,可以帮助开发者发现代码质量问题和提出一些改进建议.除了检查 ...

  6. 静态代码扫描工具汇总

    一.概述 在软件开发过程中,开发团队往往要花费大量的时间和精力发现并修改代码缺陷.传统的代码评审.同事复审,通过人工方式来检查缺陷仍然是一件耗时耗力的事情.而静态代码扫描工具能够在代码构建过程中帮助开 ...

  7. 想做一个整合开源安全代码扫描工具的代码安全分析平台 - Android方向调研

    想做一个整合开源安全代码扫描工具的代码安全分析平台 - Android方向调研 http://blog.csdn.net/testing_is_believing/article/details/22 ...

  8. java 静态扫描_静态代码扫描工具 – (八)- 扫描Java项目

    静态代码扫描工具 – (八)- 扫描Java项目 1.准备好Java项目代码 只要是java语言实现的项目均可. 比如,自动化测试的代码,测试平台等均可以. 本次案例,使用java语言实现的测试平台来 ...

  9. Java学习之代码扫描工具的使用方法

    有些刚进行Java学习的小伙伴对Java代码扫描工具还不是很了解,不知道该如何使用,下面千锋重庆的小编就来告诉大家使用方法. 1.插件的安装 由于使用的mac所有以Mac下idea插件安装流程为例,首 ...

最新文章

  1. linux-dash安装和使用
  2. 【腾讯Bugly干货分享】H5 视频直播那些事
  3. 【Luogu3932】浮游大陆的68号岛
  4. 域模型向左走(充血),向右走(贫血)
  5. 小程序开发语言python_小程序是用什么语言开发的?5种最佳语言分享
  6. libevent: linux安装libevent
  7. 游戏教玩家学java,技术|帮你学习Java语言的游戏
  8. wxpython制作表格界面_Python wxPython库使用wx.ListBox创建列表框示例
  9. 创建visual basic2005 数据库
  10. android霓虹灯源代码——基础编
  11. 工业上服务器无线投屏到电视,台式电脑支持无线投屏吗 如何投屏到电视上
  12. C++程序设计之客户消费积分管理
  13. 小公司如何做项目管理流程
  14. 浙大计算机考研导学,2016届浙大计算机考研复习经验整理
  15. 数据库与关键字同名解决方法
  16. 二十年架构师整理出的Java学习路线,学完年薪百万
  17. C语言求满足条件的xyz,c++编程,已知有式子:xyz+yzz=532, 其中x、y、z为数字,编写程序输出所有满足条件的x、y和z。...
  18. “模块版”波士顿动力的Handle圣诞来袭,原来做个轮腿机器人可以这么简单
  19. Android Studio中xml文件添加注释
  20. Http RFC总结

热门文章

  1. 计算机 常用命令(超详细)
  2. html绝对路径设置,html绝对路径修改为相对路径
  3. 树莓派练手小项目---基于树莓派构建天气查询系统,实现内容的网页自动化检索功能
  4. 西安尚学堂JSP常见面试题目合集
  5. 无线网可以用电脑没有网络连接到服务器,电脑无线网络可以用但是有些网络不能用的原因...
  6. c语言写入文件不完整,求大神看看为什么不能将数据写入文件
  7. 升级glibc2.27
  8. 不要透支别人对你的善意
  9. 利用ROS采集VLP-16激光雷达数据
  10. 夫妇利用网络游戏外挂牟利200万 被提起公诉