pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.32k stars 1.14k forks source link

Non-deterministic output from the code similarity check #9937

Open praiskup opened 1 month ago

praiskup commented 1 month ago

Bug description

The output message "Similar lines in files" is not deterministic on reported module paths.

Originally debugged here: https://github.com/fedora-copr/vcs-diff-lint/issues/30

Configuration

No response

Command used

$ git clone https://github.com/rpm-software-management/mock.git
$ cd mock && git checkout cf1cb1329694e7cff16bc35faf5837e5c9fad393
# See the output is changing:
$ while true; do pylint mock/py/mockbuild/backend.py mock/py/mockbuild/buildroot.py mock/py/mockbuild/plugins/rpkg_preprocessor.py mock/py/mockbuild/plugins/rpmautospec.py mock/tests/plugins/test_rpmautospec.py | grep Similar -A1 | grep == ; done
==mockbuild.plugins.rpkg_preprocessor:[110:118]
==py.mockbuild.plugins.rpkg_preprocessor:[110:118]
==py.mockbuild.plugins.rpkg_preprocessor:[110:118]
==mockbuild.plugins.rpkg_preprocessor:[110:118]
==py.mockbuild.plugins.rpkg_preprocessor:[110:118]
==py.mockbuild.plugins.rpkg_preprocessor:[110:118]
==mockbuild.plugins.rpkg_preprocessor:[110:118]
==mockbuild.plugins.rpkg_preprocessor:[110:118]
==mockbuild.plugins.rpkg_preprocessor:[110:118]
==py.mockbuild.plugins.rpkg_preprocessor:[110:118]
==py.mockbuild.plugins.rpkg_preprocessor:[110:118]
==py.mockbuild.plugins.rpkg_preprocessor:[110:118]

Pylint output

************* Module tests.plugins.test_rpmautospec
mock/tests/plugins/test_rpmautospec.py:1:0: R0801: Similar lines in 2 files
==py.mockbuild.plugins.rpkg_preprocessor:[110:118]
==py.mockbuild.plugins.rpmautospec:[116:124]
        self.buildroot.doChroot(
            command,
            shell=False,
            cwd=chroot_sources,
            logger=self.buildroot.build_log,
            uid=self.buildroot.chrootuid,
            gid=self.buildroot.chrootgid,

Expected behavior

************* Module tests.plugins.test_rpmautospec
mock/tests/plugins/test_rpmautospec.py:1:0: R0801: Similar lines in 2 files
==mockbuild.plugins.rpkg_preprocessor:[110:118]
==mockbuild.plugins.rpmautospec:[116:124]
        self.buildroot.doChroot(
            command,
            shell=False,
            cwd=chroot_sources,
            logger=self.buildroot.build_log,
            uid=self.buildroot.chrootuid,
            gid=self.buildroot.chrootgid,

Pylint version

python3-pylint-3.2.5-1.fc40.noarch
python3-pylint-3.2.5-2.fc41.noarch

OS / Environment

Fedora 40 and 41

Additional dependencies

No response