Tribler / dispersy

The elastic database system. A database designed for P2P-like scenarios, where potentially millions of computers send database updates around.
http://www.tribler.org
86 stars 43 forks source link

Code readability and resolve pylint warnings #8

Open synctext opened 11 years ago

synctext commented 11 years ago

Goal: make code easier to understand for new developers and reduce pylint errors/warnings

Currently there are some automatic warning (not all need fixing): http://jenkins.tribler.org/jenkins/job/Test_dispersy_devel/616/violations/

First pylint warning is moving functionality away from the main dispersy.py in order to reduce it, from the current 4631 SLOC: http://jenkins.tribler.org/jenkins/job/Test_dispersy_devel/616/violations/file/tribler/Tribler/dispersy/dispersy.py/

Feedback is needed: what to change

boudewijn-tribler commented 11 years ago

I agree, less pylint errors/warnings will greatly benefit the code base. Yet, pylint has a fairly strict default configuration, so before we start fixing things that are not broken, we should agree on what we want pylint (not) to check.

Let us take dispersy.py as an example. The following are a few [C]onvention for coding standard violations that occur:

There are a few [W]arning for stylistic problems or minor programming issues that we should discuss as well:

whirm commented 11 years ago
boudewijn-tribler commented 11 years ago

We will add a pylint.rc file to the repository with the settings that we agree on. After a discussion with Elric we came with the following:

[MESSAGES CONTROL]
disable=C0321,W0142

[FORMAT]
max-line-length=120
max-module-lines=3000

[BASIC]
no-docstring-rgx=_.*
whirm commented 11 years ago

I've added the config file to jenkins, Ill be progressively updating the projects to use it. Right now only Test_dispersy_devel is using it.

I will also periodically update the number of violations that mark a build as failure and no pull requests that go over the threshold should be merged.

boudewijn-tribler commented 11 years ago

autopep8 can be run from console to fix many problems in one go. I suggest running this on all code, running it locally before doing a merge will prevent merge problems occurring.

/usr/local/bin/autopep8 --in-place --max-line-length=120 --jobs=0 --recursive --pep8-passes=3 .

boudewijn-tribler commented 11 years ago

/usr/local/bin/autopep8 --in-place --max-line-length=120 --ignore=E501 --jobs=0 --recursive --pep8-passes=3 .

Ignoring E501 will leave line lengths alone. This results in less invasive changes, while still doing the changes that Eclipse does.

whirm commented 10 years ago

I guess we can close this one now.