Closed seisman closed 3 years ago
Lots of duplicate-code
recommendations in the error message log:
The docs at http://pylint.pycqa.org/en/2.7/technical_reference/features.html#similarities-checker-messages says:
Similar lines in %s files Indicates that a set of similar lines has been detected among multiple file. This usually means that the code should be refactored to avoid this duplication.
So we should tweak our .pylintrc
file a bit following https://stackoverflow.com/questions/29206482/pylint-duplicate-code-false-positive (using ignore-imports=yes
should fix most warnings).
Also take this as a cue to refactor some of the duplicate code. I was going to create a virtualfile_from_data()
function to replace this common block of code in our functions:
with Session() as lib:
# Choose how data will be passed in to the module
if kind == "file":
file_context = dummy_context(data)
elif kind == "matrix":
file_context = lib.virtualfile_from_matrix(data)
elif kind == "vectors":
file_context = lib.virtualfile_from_vectors()
Still a lot of warnings after setting ignore-imports=yes
. Perhaps better to disable duplicate-code
and try to refactor later.
Yes, I'll open a separate issue for refactoring. Do you want to go ahead and update .pylintrc
?
Description of the problem
See the "Style Checks" runs in https://github.com/GenericMappingTools/pygmt/pull/944 for details.