diff --git a/slither/tools/mutator/__main__.py b/slither/tools/mutator/__main__.py index dea11676a6..d97806e286 100644 --- a/slither/tools/mutator/__main__.py +++ b/slither/tools/mutator/__main__.py @@ -77,15 +77,6 @@ def parse_args() -> argparse.Namespace: default=False, ) - # to print just all the mutants - parser.add_argument( - "-vv", - "--very-verbose", - help="log mutants that are caught, uncaught, and fail to compile. And more!", - action="store_true", - default=False, - ) - # select list of mutators to run parser.add_argument( "--mutators-to-run", @@ -159,7 +150,6 @@ def main() -> None: # pylint: disable=too-many-statements,too-many-branches,too timeout: Optional[int] = args.timeout solc_remappings: Optional[str] = args.solc_remaps verbose: Optional[bool] = args.verbose - very_verbose: Optional[bool] = args.very_verbose mutators_to_run: Optional[List[str]] = args.mutators_to_run comprehensive_flag: Optional[bool] = args.comprehensive @@ -167,7 +157,6 @@ def main() -> None: # pylint: disable=too-many-statements,too-many-branches,too if paths_to_ignore: paths_to_ignore_list = paths_to_ignore.strip("][").split(",") - logger.info(blue(f"Ignored paths - {', '.join(paths_to_ignore_list)}")) else: paths_to_ignore_list = [] @@ -178,6 +167,8 @@ def main() -> None: # pylint: disable=too-many-statements,too-many-branches,too # get all the contracts as a list from given codebase sol_file_list: List[str] = get_sol_file_list(Path(args.codebase), paths_to_ignore_list) + logger.info(blue("Preparing to mutate files:\n- " + "\n- ".join(sol_file_list))) + # folder where backup files and uncaught mutants are saved if output_dir is None: output_dir = "./mutation_campaign" @@ -247,9 +238,11 @@ def main() -> None: # pylint: disable=too-many-statements,too-many-branches,too # lines those need not be mutated (taken from RR and CR) dont_mutate_lines = [] - # mutation + # perform mutations on {target_contract} in file {file_name} + # setup placeholder val to signal whether we need to skip if no target_contract is found target_contract = "SLITHER_SKIP_MUTATIONS" if contract_names else "" try: + # loop through all contracts in file_name for compilation_unit_of_main_file in sl.compilation_units: for contract in compilation_unit_of_main_file.contracts: if contract.name in contract_names and contract.name not in mutated_contracts: @@ -287,7 +280,6 @@ def main() -> None: # pylint: disable=too-many-statements,too-many-branches,too target_contract, solc_remappings, verbose, - very_verbose, output_folder, dont_mutate_lines, ) @@ -372,8 +364,6 @@ def main() -> None: # pylint: disable=too-many-statements,too-many-branches,too logger.info(magenta("Zero Tweak mutants analyzed\n")) # Reset mutant counts before moving on to the next file - if very_verbose: - logger.info(blue("Reseting mutant counts to zero")) total_mutant_counts[0] = 0 total_mutant_counts[1] = 0 total_mutant_counts[2] = 0 diff --git a/slither/tools/mutator/mutators/abstract_mutator.py b/slither/tools/mutator/mutators/abstract_mutator.py index cb435f8569..2e99466d92 100644 --- a/slither/tools/mutator/mutators/abstract_mutator.py +++ b/slither/tools/mutator/mutators/abstract_mutator.py @@ -29,7 +29,6 @@ def __init__( # pylint: disable=too-many-arguments contract_instance: Contract, solc_remappings: Union[str, None], verbose: bool, - very_verbose: bool, output_folder: Path, dont_mutate_line: List[int], rate: int = 10, @@ -44,7 +43,6 @@ def __init__( # pylint: disable=too-many-arguments self.timeout = timeout self.solc_remappings = solc_remappings self.verbose = verbose - self.very_verbose = very_verbose self.output_folder = output_folder self.contract = contract_instance self.in_file = self.contract.source_mapping.filename.absolute @@ -98,7 +96,6 @@ def mutate(self) -> Tuple[List[int], List[int], List[int]]: self.timeout, self.solc_remappings, self.verbose, - self.very_verbose, ) # count the uncaught mutants, flag RR/CR mutants to skip further mutations @@ -132,18 +129,4 @@ def mutate(self) -> Tuple[List[int], List[int], List[int]]: else: self.total_mutant_counts[2] += 1 - if self.very_verbose: - if self.NAME == "RR": - logger.info( - f"Found {self.uncaught_mutant_counts[0]} uncaught revert mutants so far (out of {self.total_mutant_counts[0]} that compile)" - ) - elif self.NAME == "CR": - logger.info( - f"Found {self.uncaught_mutant_counts[1]} uncaught comment mutants so far (out of {self.total_mutant_counts[1]} that compile)" - ) - else: - logger.info( - f"Found {self.uncaught_mutant_counts[2]} uncaught tweak mutants so far (out of {self.total_mutant_counts[2]} that compile)" - ) - return self.total_mutant_counts, self.uncaught_mutant_counts, self.dont_mutate_line diff --git a/slither/tools/mutator/utils/testing_generated_mutant.py b/slither/tools/mutator/utils/testing_generated_mutant.py index d62fc3ff0e..d484ff68f8 100644 --- a/slither/tools/mutator/utils/testing_generated_mutant.py +++ b/slither/tools/mutator/utils/testing_generated_mutant.py @@ -91,7 +91,6 @@ def test_patch( # pylint: disable=too-many-arguments timeout: int, mappings: Union[str, None], verbose: bool, - very_verbose: bool, ) -> int: """ function to verify whether each patch is caught by tests @@ -118,7 +117,7 @@ def test_patch( # pylint: disable=too-many-arguments return 0 # uncaught else: - if very_verbose: + if verbose: logger.info( yellow( f"[{generator_name}] Line {patch['line_number']}: '{patch['old_string']}' ==> '{patch['new_string']}' --> COMPILATION FAILURE"