2

我正在领导一个大型 python 项目,它使用 Django(model)、celery、python。现在,我只是发现代码质量失控了。问题是:

  1. 提交给 git 的代码有一些基本的程序员错误(它必须被测试覆盖)
  2. Sever 人向一个分支提交代码。(我们使用git flow,它需要经常合并)

对于问题 1,我正在考虑使用 Pylint ,但是我们的项目很大,并且有很多依赖项(Django,Celery)。

pylint可以很好地工作吗?我只是试了一下pylint,好像会报一些误导性的错误,好像django.objects不存在。那么,您对项目进行质量控制的最佳实践是什么?

对于问题2,我不知道如何改进它?

4

2 回答 2

0

我不熟悉其他 python 代码检查器,但我可以告诉你我在一个小型 Django 项目中使用 Pylint 的经验。

它给出了很多错误的错误。在这些类别中似乎存在过多的错误错误与可能丢失的合法错误之间的权衡。我在已经测试和运行的代码上使用它,所以现在我已经将它配置为忽略大多数这些类别。

这是我目前的 .pylintrc 设置

如果您希望它检查导入是否有效,请将内容添加到路径中

[MASTER]

init-hook='import sys; sys.path.append("...your directories...")

我的自由主义忽略了经常给出误报的错误消息。

[MESSAGES CONTROL]

# E1002: use of super on old style class
# E1101: __ has no __ member
# E1103: maybe no member
# F0401: couldn't import
# R0924: badly implemented container (false pos on forms.Form subclassers)
# W0232: class has no __init__ (when inheriting)
# W0613: unused-argument (functions that are supposed to always take request/obj)
disable=E1002,E1101,E1103,F0401,R0903,R0924,W0232,W0613

添加一些自动成员以避免一些常见的E1101,如果你想启用该检查

[TYPECHECK]

generated-members=REQUEST,acl_users,aq_parent,objects,_meta,id,pk

希望对 Django + Pylint 有所帮助。

于 2013-06-12T00:44:20.717 回答
0

If you are open to use a SaaS solution, feel free to check out QuantifiedCode (https://www.quantifiedcode.com).

It's an online tool for automated, continuous code review and intelligence and completely free for open-source projects. It has Github integration and provides a large range of customizable code checks (both general-purpose and library-specific checks e.g. for Django), as well as metrics for your project (disclosure: I'm the CTO).

Our code checker is open-source as well and can be found on Github:

https://github.com/quantifiedcode/checkmate

There are similar tools that you should check out as well, e.g. Landscape (www.landscape.io), CodeClimate (www.codeclimate.com), Codacy(www.codacy.com) or SonarSource (www.sonarsource.com - self hosted solution). Most of them provide a free tier for open-source projects as well.

于 2015-08-03T16:09:47.783 回答