Skip to content

duplicate-code are always counted on the last module checked #2368

@mthuurne

Description

@mthuurne

Steps to reproduce

Have pylint check multiple modules in a single invocation. There should be duplicate lines among these modules.

pylint -ry *.py

Current behavior

The R0801 messages will be issued on the last module checked, regardless of which modules contained the duplicate lines:

xmlgen.py:1:0: R0801: Similar lines in 2 files
==databaselib:11
==projectlib:18
import logging
import os
import os.path
import re
import time (duplicate-code)

This distorts the statistics, in particular the % errors / warnings by module report. The xmlgen.py module in the code I'm checking gets blamed for 68% of refactor issues, even though it contains 0 issues if checked individually.

Expected behavior

One option would be to issue duplicate code on all modules that contain it. That would inflate its count a bit, but I don't think that would be a major problem.

Another option could be to create a pseudo-module on which all duplicates are reported. So it would be much like the current situation, but without an existing module's stats being distorted.

pylint --version output

pylint 2.0.1
astroid 2.0.1
Python 3.4.6 (default, Mar 22 2017, 12:26:13) [GCC]

Metadata

Metadata

Labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions