-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMP] pylint-odoo: Adding support for parameters --ignore and --ignore-patterns #103
[IMP] pylint-odoo: Adding support for parameters --ignore and --ignore-patterns #103
Conversation
""" | ||
self.ext_files = {} | ||
base_path = os.path.dirname(os.path.realpath(__file__)) | ||
ignores = [] | ||
ignore_argvs = getopt.getopt([argv for argv in sys.argv[1:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameters are received with sys.argv but when run with setup.py or tox that variable is empty.
Could you help me with this @moylop260 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameters are received from config
like as other custom parameters.
Because a configfile could be used too.
Search where is used the config
variable to read by example the js configuration file for js-lint check
84f871a
to
25cc9d0
Compare
@@ -237,6 +237,20 @@ class ModuleChecker(misc.WrapperModuleChecker): | |||
'javascript lint. You can use the environment variable ' | |||
'"PYLINT_ODOO_JSLINTRC" too. Default: %s' % DFTL_JSLINTRC) | |||
}), | |||
('po-ignore', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try to use --ignore
but enter in conflict with ignore
of pylint
It is a good solucion?
Yeah
Its right.
The idea is use the same parameter of pylint.
El 06/01/2017 8:58 a.m., "Jesus Zapata" <notifications@github.com> escribió:
… ***@***.**** commented on this pull request.
------------------------------
In pylint_odoo/checkers/modules_odoo.py
<#103 (review)>
:
> @@ -237,6 +237,20 @@ class ModuleChecker(misc.WrapperModuleChecker):
'javascript lint. You can use the environment variable '
'"PYLINT_ODOO_JSLINTRC" too. Default: %s' % DFTL_JSLINTRC)
}),
+ ('po-ignore', {
I try to use --ignore but enter in conflict with ignore of pylint
It is a good solucion?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#103 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGVh27phRqZHWzmd3bxVt1K0h83sqhpNks5rPlaLgaJpZM4Lb9ja>
.
|
Now used the correct parameters --ignore and --ignore-patterns ! |
86df315
to
a442815
Compare
ignores_patterns = [glob.glob(os.path.join(base_path, ignore.pattern)) | ||
for ignore | ||
in self.linter.option_value('ignore-patterns')] | ||
for ignore in ignores_patterns: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about use utils._basename_in_blacklist_re method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay! Thanks for the information of this method ! I started using it!
for ignore in self.linter.option_value('ignore')] | ||
ignores_patterns = [glob.glob(os.path.join(base_path, ignore.pattern)) | ||
for ignore | ||
in self.linter.option_value('ignore-patterns')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not tested this code but I don't understand how works if the arg.dest
for this parameter is black_list_re
Check if It have the same content, please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very well, I did not know that parameter! I'm using it now
""" | ||
self.ext_files = {} | ||
base_path = os.path.dirname(os.path.realpath(__file__)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need the path of pylint_odoo/misc.py
file here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used another variable what store same value!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try to use another variable and do not pass the tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a commenr in the code of why is required this value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: "because do not pass the test" is not a good justify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you run manually the command pylint
with ignore with other path won't work.
I mean, copy test_repo to /tmp/
and check if ignore parameters are working yet.
if ignore in root: | ||
find = False | ||
continue | ||
if find: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cyclomatic complexity of this method is too high.
Could you refactoring it to reduce it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this array should be traversed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But with the continue
breaks the cycle
1ddde14
to
1c88591
Compare
910e124
to
5a5375f
Compare
self.linter.config. | ||
black_list_re): | ||
find = False | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A continue
as last sentence of a for
is useless.
Maybe you want use break
'--enable=javascript-lint'] | ||
pylint_res = self.run_pylint(self.paths_modules, extra_params) | ||
real_errors = pylint_res.linter.stats['by_msg'] | ||
self.assertEqual(real_errors.items(), []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should force a output in order to validate that was skipped files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed test cases!
Maybe is working the original parameter, because you are skipping a full folder. And remove the following line: |
@moylop260 Thanks for you observation! The previous code did not find the files |
fext = os.path.splitext(filename)[1].lower() | ||
fname_rel = os.path.relpath( | ||
os.path.join(root, filename), self.module_path) | ||
self.ext_files.setdefault(fext, []).append(fname_rel) | ||
name = os.path.join(self.module_path, fname_rel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you deleting a value to add it again?
I mean, you have os.path.join(root, filename)
:
- e.g.
/mypath1/mypath2/myfile.ext
Then you get relative path
based on self.module_path
- e.g. If
self.module_path
is/mypath1
then the relative path ismypath2/myfile.ext
after that you are joining again theself.module_path
to get/mypath1/mypath2/myfile.ext
again.
Do you want drive me crazy or Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand.
When run pylint -r n --disable=all --enable=deprecated-openerp-xml-node --ignore=test_module/res_users.xml --load-plugins=pylint_odoo /tmp/test_repo/
The variable self.linter.config.black_list
has ['test_module/res_users.xml']
I only ask if ignore in name:
the name variable has '/tmp/test_repo/test_module/res_users.xml'
Does this help you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a pdb and print the value os.path.join(root, filename)
and name
and tell me what is the difference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Output of pdb
(Pdb++) os.path.join(root, filename)
'/tmp/test_repo/test_module/res_users.xml'
(Pdb++) name
'/tmp/test_repo/test_module/res_users.xml'
They are the same values!
I can remove the variable name
and use os.path.join (root, filename)
directly
Is that what you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I told you
You are using a=10; a+=1; a-=1
😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks to you, i have fixed it!
# If the file is within ignores is ignored | ||
for ignore in self.linter.config.black_list: | ||
if ignore in name: | ||
find = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What means find
variable?
(Because I don't understand why we have a find = False
when is really find it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have fixed this, I give a better use to the variable
@moylop260 |
fext = os.path.splitext(filename)[1].lower() | ||
fname_rel = os.path.relpath( | ||
os.path.join(root, filename), self.module_path) | ||
self.ext_files.setdefault(fext, []).append(fname_rel) | ||
# If the file is within black_list_re is ignored |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fname = os.path.join(root, filename)
And reuse this variable 2 times
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have used the variable when needed!
find = True | ||
break | ||
if not find: | ||
self.ext_files.setdefault(fext, []).append(fname_rel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assign fname_rel
variable here where is really used.
""" | ||
self.ext_files = {} | ||
ignores = list(self.linter.config.black_list) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need this variable instead of use it directly?
NOTE: I requested a explanation, don't confuse with a request of change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable is not necessary since it is used only once!
This change had been made by the 188d405 commit excluding the test folder
Can I return this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarify.
Yes, please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just waiting justification of variable ignores
97fbd70
to
ec722f6
Compare
Please create PR to oca from merged sha |
Done the PR OCA#103 |
…-for-ignore-files-jesuszapata [IMP] pylint-odoo: Adding support for parameters --ignore and --ignore-patterns
pylint supports the following parameters:
--ignore=<file>[,<file>...]
--ignore-patterns=<pattern>[,<pattern>...]
But pylint-odoo is not using for ignore them from custom search files methods.
We are searching files: js, md, rst...
And we need skip them too if this parameters is defined.
Doubts you have:
Related to issue #102