diff options
author | Frank Harrison <frank@doublethefish.com> | 2020-03-26 10:50:55 +0000 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-01-02 09:56:39 +0100 |
commit | 579b58d3583fb0efac58aaa8e4d63f6dcb05b0bb (patch) | |
tree | 38a4cfd80e1a6cc9418d5551bd68de2bef2a3509 /tests/input | |
parent | 854a7f55823206b8bd9d91095c3ca12d78d63f2a (diff) | |
download | pylint-git-579b58d3583fb0efac58aaa8e4d63f6dcb05b0bb.tar.gz |
mapreduce| Adds map/reduce functionality to SimilarChecker
Before adding a new mixin this proves the concept works, adding tests as
examples of how this would work in the main linter.
The idea here is that, because `check_parallel()` uses a multiprocess
`map` function, that the natural follow on is to use a 'reduce`
paradigm. This should demonstrate that.
Diffstat (limited to 'tests/input')
-rw-r--r-- | tests/input/similar_lines_a.py | 63 | ||||
-rw-r--r-- | tests/input/similar_lines_b.py | 36 |
2 files changed, 99 insertions, 0 deletions
diff --git a/tests/input/similar_lines_a.py b/tests/input/similar_lines_a.py new file mode 100644 index 000000000..65a72a79d --- /dev/null +++ b/tests/input/similar_lines_a.py @@ -0,0 +1,63 @@ +""" A file designed to have lines of similarity when compared to similar_lines_b + +We use lorm-ipsum to generate 'random' code. """ +# Copyright (c) 2020 Frank Harrison <frank@doublethefish.com> + + +def adipiscing(elit): + etiam = "id" + dictum = "purus," + vitae = "pretium" + neque = "Vivamus" + nec = "ornare" + tortor = "sit" + return etiam, dictum, vitae, neque, nec, tortor + + +class Amet: + def similar_function_3_lines(self, tellus): # line same #1 + agittis = 10 # line same #2 + tellus *= 300 # line same #3 + return agittis, tellus # line diff + + def lorem(self, ipsum): + dolor = "sit" + amet = "consectetur" + return (lorem, dolor, amet) + + def similar_function_5_lines(self, similar): # line same #1 + some_var = 10 # line same #2 + someother_var *= 300 # line same #3 + fusce = "sit" # line same #4 + amet = "tortor" # line same #5 + return some_var, someother_var, fusce, amet # line diff + + def __init__(self, moleskie, lectus="Mauris", ac="pellentesque"): + metus = "ut" + lobortis = "urna." + Integer = "nisl" + (mauris,) = "interdum" + non = "odio" + semper = "aliquam" + malesuada = "nunc." + iaculis = "dolor" + facilisis = "ultrices" + vitae = "ut." + + return ( + metus, + lobortis, + Integer, + mauris, + non, + semper, + malesuada, + iaculis, + facilisis, + vitae, + ) + + def similar_function_3_lines(self, tellus): # line same #1 + agittis = 10 # line same #2 + tellus *= 300 # line same #3 + return agittis, tellus # line diff diff --git a/tests/input/similar_lines_b.py b/tests/input/similar_lines_b.py new file mode 100644 index 000000000..21634883d --- /dev/null +++ b/tests/input/similar_lines_b.py @@ -0,0 +1,36 @@ +""" The sister file of similar_lines_a, another file designed to have lines of +similarity when compared to its sister file + +As with the sister file, we use lorm-ipsum to generate 'random' code. """ +# Copyright (c) 2020 Frank Harrison <frank@doublethefish.com> + + +class Nulla: + tortor = "ultrices quis porta in" + sagittis = "ut tellus" + + def pulvinar(self, blandit, metus): + egestas = [mauris for mauris in zip(blandit, metus)] + neque = (egestas, blandit) + + def similar_function_5_lines(self, similar): # line same #1 + some_var = 10 # line same #2 + someother_var *= 300 # line same #3 + fusce = "sit" # line same #4 + amet = "tortor" # line same #5 + iaculis = "dolor" # line diff + return some_var, someother_var, fusce, amet, iaculis, iaculis # line diff + + +def tortor(self): + ultrices = 2 + quis = ultricies * "porta" + return ultricies, quis + + +class Commodo: + def similar_function_3_lines(self, tellus): # line same #1 + agittis = 10 # line same #2 + tellus *= 300 # line same #3 + laoreet = "commodo " # line diff + return agittis, tellus, laoreet # line diff |