Commit a4857b78 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

Keep track of the name of the modified code when applying fixers

We can then execute the following query, for example, to find out the
bits of code for which there is no information traced at runtime:

(This is an example for the "division" problem)

SELECT filename
FROM modified
WHERE fixer = "division"
AND filename NOT IN
  (SELECT filename
   FROM division)
parent 86a52e15
......@@ -44,17 +44,22 @@ def get_fixers():
]
trace_modified = create_table("modified", "fixer", "filename")
def apply_fixers(string, name):
# This function is inspired by refactoring_tool.refactor_file
refactoring_tool = RefactoringTool(fixer_names=get_fixers())
encoding = tokenize.detect_encoding(lambda: string)[0]
string = string.decode(encoding) + u"\n" # '\n' to silence certain parse errors
for fixer in get_fixers():
refactoring_tool = RefactoringTool(fixer_names=[fixer])
tree = refactoring_tool.refactor_string(string, name)
if tree.was_changed:
trace_modified(fixer[17:-6], name)
string = unicode(tree)
string += "\n" # Silence certain parse errors
s = string.decode(encoding)
s = refactoring_tool.refactor_string(s, name)
# The [:-1] is to take off the \n we added earlier
return unicode(s)[:-1].encode(encoding)
return string[:-1].encode(encoding)
init_py = '__init__' + os.extsep + 'py'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment