Skip to content

Commit

Permalink
[FIX] attribute-string-redundant: Use just capitalize and title valid…
Browse files Browse the repository at this point in the history
… names
  • Loading branch information
Jesus Zapata authored and moylop260 committed Jan 26, 2017
1 parent 2b55e20 commit bccb6a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pylint_odoo/checkers/no_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,13 @@ def visit_call(self, node):
for argument in args:
argument_aux = argument
# Check this 'name = fields.Char("name")'
field_name = (argument.parent.parent.targets[0].name
.replace('_', ' '))
if (isinstance(argument, astroid.Const) and
(index ==
FIELDS_METHOD.get(argument.parent.func.attrname, 0)) and
(argument.value.lower().replace(' ', '_') ==
argument.parent.parent.targets[0].name)):
(argument.value in
[field_name.capitalize(), field_name.title()])):
self.add_message('attribute-string-redundant', node=node)
if isinstance(argument, astroid.Keyword):
argument_aux = argument.value
Expand Down Expand Up @@ -444,8 +446,8 @@ def visit_call(self, node):
# Check if the param string is equal to the name
# of variable
elif argument.arg == 'string' and \
(argument.parent.parent.targets[0].name ==
argument.value.value.lower().replace(' ', '_')):
(argument.value.value in
[field_name.capitalize(), field_name.title()]):
self.add_message(
'attribute-string-redundant', node=node)
if isinstance(argument_aux, astroid.CallFunc) and \
Expand Down
5 changes: 5 additions & 0 deletions pylint_odoo/test_repo/broken_module/models/broken_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ class TestModel(models.Model):
"Many 2 Many Variable 2",
help="Help")

field_case_sensitive = fields.Char(
'Field Case SENSITIVE',
help="Field case sensitive"
)

name_equal_to_string = fields.Float(
"Name equal to string",
help="Name Equal To String"
Expand Down

0 comments on commit bccb6a8

Please sign in to comment.