Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
[REF] pylint_pr.cfg: Enable check to validate CamelCase class name fo…
Browse files Browse the repository at this point in the history
…r odoo version >= 8.0
  • Loading branch information
moylop260 committed Aug 18, 2015
1 parent ed542ce commit a84855a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -32,7 +32,8 @@ env:
- VERSION="7.0" INCLUDE="test_module,second_module" ODOO_REPO="OCA/OCB" # ODOO_REPO usage example
- VERSION="6.1" INCLUDE="test_module,second_module"
- LINT_CHECK="1" TESTS="0" PYLINT_EXPECTED_ERRORS="17" TRAVIS_PULL_REQUEST="false" # Use main pylint config file
- LINT_CHECK="1" TESTS="0" PYLINT_EXPECTED_ERRORS="18" TRAVIS_PULL_REQUEST="true" # Use PR pylint config file
- VERSION="master" LINT_CHECK="1" TESTS="0" PYLINT_EXPECTED_ERRORS="18" TRAVIS_PULL_REQUEST="true" # Use PR pylint config file
- VERSION="7.0" LINT_CHECK="1" TESTS="0" PYLINT_EXPECTED_ERRORS="17" TRAVIS_PULL_REQUEST="true" # Use PR pylint config file but with params changed by odoo version

install:
- cp -r ../maintainer-quality-tools/ $HOME
Expand Down
15 changes: 12 additions & 3 deletions travis/cfg/travis_run_pylint_pr.cfg
Expand Up @@ -6,9 +6,7 @@ cache-size=500

[MESSAGES CONTROL]
disable=all
# This change don't add new checks.
# Adding one exits check to test the pr-diff feature
enable=W0403
enable=invalid-name,

[REPORTS]
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
Expand All @@ -21,6 +19,17 @@ comment=no
[FORMAT]
indent-string=' '

[BASIC]
class-rgx=[A-Z_][a-zA-Z0-9]{2,45}
module-rgx=.*
const-rgx=.*
function-rgx=.*
method-rgx=.*
attr-rgx=.*
argument-rgx=.*
variable-rgx=.*
inlinevar-rgx=.*

[SIMILARITIES]
ignore-comments=yes
ignore-docstrings=yes
Expand Down
33 changes: 31 additions & 2 deletions travis/test_pylint
Expand Up @@ -11,13 +11,41 @@ import run_pylint

from getaddons import get_modules_changed


def get_extra_params(odoo_version):
'''
Get extra pylint params by odoo version
:param version: String with name of version of odoo
:return: List of extra pylint params
'''
params = []
try:
version_f = float(odoo_version)
except ValueError:
# master case
version_f = -1
if version_f != -1 and version_f < 8:
# Class name snake_case style to version < 8
params.append(
'--class-rgx='
'([a-z_][a-z0-9_]{2,45})|([A-Z_][a-zA-Z0-9]{2,45})$'
)
return params

version = os.environ.get('VERSION', False)
extra_params_cmd = []
if version:
extra_params = get_extra_params(version)
for extra_param in extra_params:
extra_params_cmd.extend([
'--extra-params', extra_param])
pylint_rcfile = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
'cfg',
"travis_run_pylint.cfg")
count_errors = run_pylint.main([
"--config-file=" + pylint_rcfile,
], standalone_mode=False)
] + extra_params_cmd, standalone_mode=False)


pylint_rcfile_pr = os.path.join(
Expand All @@ -42,7 +70,8 @@ if is_pull_request and branch_base and git_work_dir:
])
count_errors += run_pylint.main([
"--config-file=" + pylint_rcfile_pr,
] + modules_changed_cmd, standalone_mode=False)
] + extra_params_cmd + modules_changed_cmd,
standalone_mode=False)

else:
# TODO: Add git hook case in other PR
Expand Down

0 comments on commit a84855a

Please sign in to comment.