-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
6f37c91
commit d1bbd4c
Showing
4 changed files
with
268 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
|
||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
|
||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters