Commit Graph

22 Commits (65e132a734f005f090a384bfa129482d195c6d6e)

Author SHA1 Message Date
zhulingjie ff50886d79 Update hacking version to latest
This resolves extranous "improper escape sequence" warnings on
python 3.6+[1].

Note, this does not resolve those warnings from pylint. There
is already another proposed patch to address pylint[2].

[1] https://review.opendev.org/494322
[2] https://review.opendev.org/635236

Change-Id: Ie160436913e4d935bab118d31ba10193ac38bd8f
4 years ago
Michael Johnson ff1e933eef Improve local hacking checks test coverage
This patch improves the unit test coverage for the local hacking checks.
It also removes the "no_author_tags" check as it is now covered in the
main hacking rule H105.

Change-Id: I4029f4fa2e28f4f50c1897b6216c0d8557b2a56b
4 years ago
Doug Hellmann 0322cbc5c3 fix tox python3 overrides
We want to default to running all tox environments under python 3, so
set the basepython value in each environment.

We do not want to specify a minor version number, because we do not
want to have to update the file every time we upgrade python.

We do not want to set the override once in testenv, because that
breaks the more specific versions used in default environments like
py35 and py36.

This patch also updates pylint to 1.5.6 which is compatible with
python3.
In updating pylint we have some issues to correct, this patch addresses
those issues so the Octavia code passes pylint 1.5.6.

Change-Id: Iec21f4c803a427059d595612336d67a35ebf9585
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
5 years ago
Michael Johnson 5af7133a02 Align logging on oslo_log
This patch aligns all of Octavia to use oslo_log instead of the built
in python logging. This should provide consistent log formats.

It adds a hacking check to make sure "logging" doesn't come back into
the code.

Change-Id: I9b76c2bb5a5c396faf85df4606f2ca00f23de913
5 years ago
Michael Johnson 8b94afd4ec Creates provider driver base class and exceptions
This patch creates the provider driver base class and exceptions.

See the "Enable Provider Driver Support" specification [1] for details.

[1] https://docs.openstack.org/octavia/latest/contributor/specs/version1.1/ \
    enable-provider-driver.html

This patch also improves the wording of hacking check O316 for
assertIsInstance.

Change-Id: I4262b9a772c43a702372b8389320858f06ac9720
5 years ago
Jacky Hu 649b33d247 Add license for empty __init__.py
This also fix build-openstack-sphinx-docs, there was a change introduced
in sphinx 1.6.6:
https://github.com/sphinx-doc/sphinx/pull/4335/files

If the size of __init__.py is less than 2, then the module would be
skipped which will cause the sphinx consistency checking failing later.

Change-Id: I9d8764b6e907aceed8bb8a9b04711145d0eb32ad
5 years ago
Michael Johnson c3754dbf5a Fix a bad revert method and add hacking check
This patch fixes a revert method that was not handling extra parameters
being passed to it.
It also adds a hacking check to make sure this does not happen in the
future.
The patch also breaks the bad habit of compiling regex strings for every
line of code in the project.

Change-Id: If29e377204432e215bfea97f9d76bce0a442f4c8
6 years ago
Michael Johnson 93c8e006ce Update Octavia docs for documentation migration
This patch updates the Octavia documentation in support of the
OpenStack documentation migration[1].

[1] https://specs.openstack.org/openstack/docs-specs/specs \
    /pike/os-manuals-migration.html

Change-Id: I97fd038b8050bfe776c3fca8336d9090f8236362
Depends-On: Ia750cb049c0f53a234ea70ce1f2bbbb7a2aa9454
6 years ago
Adam Harwell 49d0085f57 Add check O346 to disallow backslash line continuation
Also remove our own check that we were ignoring.

Change-Id: Icc8d74f0ee85df742340dc147b9252eaa3eaa739
6 years ago
Michael Johnson e86414bb76 Add some hacking checks borrowed from neutron
- [O343] Python 3: do not use basestring.
- [O344] Python 3: do not use dict.iteritems.
- [O345] Usage of Python eventlet module not allowed

Change-Id: I0d70bbc4608cc08f0944b836814462acdcf7269f
6 years ago
e dc882e9d27 Remove log translations from octavia
Log messages are no longer being translated. This removes all use of
the _LE, _LI, and _LW translation markers to simplify logging and to
avoid confusion with new contributions.

This patch also adds hacking rules for the translation tags.

See: http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Co-Authored-By: Michael Johnson <johnsomor@gmail.com>
Change-Id: Ic95111d09e38b3f44fd6c85d0bcf0355c21ef545
6 years ago
WangBinbin 039395f7ee Replace six.iteritems() with .items()
we should avoid using six.iteritems to achieve iterators.
We can use dict.items instead, as it will return iterators in PY3 as well.
And dict.items/keys will be more readable.

In py2, the performance about list should be negligible

Change-Id: I153d91e884ef0ea0a760527f3dab2b8d5ed3e38e
6 years ago
Tin Lam 8d0b16292d Add hacking check to ensure not use xrange()
Added hacking check to ensure not to use xrange.  Also,
fixed issues with EoF missing newline [W391].

Change-Id: Iba8d240c042e46cb34eb6ed057534d62efb6f903
Closes-Bug: #1538118
7 years ago
zhang.lei de41db2755 Replace deprecated LOG.warn with LOG.warning
Python 3 deprecated the logger.warn method, see:
https://docs.python.org/3/library/logging.html#logging.warning
so we prefer to use warning to avoid DeprecationWarning.

Change-Id: I49544d1370e7fe083eb23752227567d8d6f24020
Closes-Bug: #1508442
7 years ago
Bo Wang 15fdc0ea7b Fix hacking rule of assert_equal_or_not_none
The rule is not robust enough result in error code existing.
Fix the code and the rule.

Change-Id: I68934d4931a6e7857a824d0af5ed571a9c3e6480
Closes-bug: #1280522
7 years ago
Bertrand Lallau 88a62cfecb Use assertIs(Not)None instead of assert(Not)Equal
Instead of using assert(Not)Equal(None, ***), developers should
use assertIs(Not)None(***) to have more clear messages in case of failure.

Change-Id: I20dd008badde8a3e87a367e7ab791ace4e117fb7
8 years ago
Bertrand Lallau 76e1e02e15 Removes the use of mutables as default args
Passing mutable objects as default args is a known Python pitfall.
We'd better avoid this. This commit changes mutable default args with
None, then use 'arg = arg or {}', 'arg = arg or []'. For unit code which
doesn't use the args , just set with None. This commit also adds hacking
check.

Change-Id: Ib4f195c9c00ca2c49579f9d62648bff7c8109fcf
Closes-Bug: #1327473
8 years ago
Bertrand Lallau 456a07f60a Update HACKING.rst to reflect real syntax checks
In the past HACKING.rst file has not been updated when needed,
this patch update HACKING.rst file for all missing syntax checks.
Furthermore rules checks have been reorder in octavia/hacking/checks.py file.

Change-Id: I34bdcca5d4cc9abad797aff118fbf4e563c42757
8 years ago
Bertrand Lallau f7a540b156 Set Hacking rules to check some tests assert
Octavia doesn't have hacking rules to check "assert" usages like:

- assertTrue(isinstance(A, class A))
- assertEqual(A, None) or assertEqual(None, A)
- assertEqual(False, A) or assertEqual(True, A)
- assertEqual(a in b, True) or assertEqual(a in b, False)

This patch introduce hacking rules just above.

Change-Id: If64402508226608b5700c8bb11e924dbc778fec3
Closes-Bug: #1511368
8 years ago
Adam Harwell e6de970a38 Adding Python 3.4 Compatibility and Tox Check
Change-Id: I2a2ec83baa13f4433e32c180d7a057553348a906
8 years ago
minwang 321bc765ae Fix Octavia complexity issues
This is for fixing the octavia issue.
We ran the Octavia code base through a static code analyser and several issues got flagged.
As an exercise we looked at each issue and are now proposing fixes to the complexity/code style issues.

Change-Id: I2fc0cf213a9f7488e7cf1dff789d98ca2deeb81f
8 years ago
Doug Wiegley 941c302757 Oslo incubator updates
Change-Id: I9559d8a6d59477f6b5ba3f82ab9ecf9b71b75f70
9 years ago