in experimental/piranha_playground/rule_inference/rule_application.py [0:0]
def refactor_codebase(self, dry_run: bool = True) -> List[PiranhaOutputSummary]:
"""
Applies the refactoring rules to the codebase.
:param dry_run: bool: A boolean that if true, runs the refactor without making actual changes. Default is True.
:return: List[PiranhaOutputSummary]: A list of summaries of the changes made by Piranha.
:raises CodebaseRefactorerException: If the refactoring fails.
"""
try:
toml_dict = toml.loads(self.rules)
rule_graph = RawRuleGraph.from_toml(toml_dict)
arguments = toml_dict.get("arguments", [{}])[0]
arguments = flatten_dict_list(arguments)
args = PiranhaArguments(
language=self.language,
paths_to_codebase=[self.path_to_codebase],
rule_graph=rule_graph.to_graph(),
dry_run=dry_run,
**arguments,
)
output_summaries = execute_piranha(args)
logger.info("Changed files:")
for summary in output_summaries:
logger.info(summary.path)
return output_summaries
except BaseException as e:
raise CodebaseRefactorerException(str(e)) from e