Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file is the center of --green-mode and contains the underlying core of this mode of coala-quickstart. * green_mode(): The master method which calls all the underlying methods in this file and many others. Some broad actions that it performs: * Creates `.project_data.yaml` to store the directory and file structure of the project, deletes it in the end. Further commits may change this behaviour and add code to reuse this data generated. * Calls the QuickstartBear to traverse the file_dict and guess some setting values on its own. * Calls the methods to provide some other information about settings of some bears which can't be detected by traversing the file_dict eg. settings based on the names of files. * Calls the methods to test each bear for each file for all the values for each setting until a green setting is found for a bear. * Will call the methods to create section object and write `.coafile` in further commits. * bear_test_fun(): Calls the methods to get all possible combinations of values to bear settings and supply these to other underlying methods to test them for each bear. * run_test_on_each_bear(): Prints a message about which bear, the tests are running on and calls local_bear_test() or global_bear_test() depending on the type of bear to guess the green setting values from the combination of all values. * local_bear_test(), global_bear_test(): Run coala repetitively on the bear in a multiprocessing environment and return the green settings found. * check_bear_results(): Checks whether the result objects returned by the bear are 0 or if they lie in the ignore scope of the code to testify whether the current bear settings are green. * get_kwargs(): Produces combinations of all setting values for the bears which are given one by one to the bear to run upon. * get_type_of_setting(): Detects the type of a bear argument, i.e. whether it accepts boolean values or something like int which falls under the category of infinite set of values, whether some setting requires a config file of a specific linter or whether an argument accepts some discrete set of values. * run_quickstartbear(): Runs QuickstartBear to guess some setting values from the file_dict and write the results to `.project_data.yaml`. * find_min_of_setting()/find_max_of_setting(): Are helper functions for bear settings that run in coordination with per file results of QuickstartBear to get the project minima/maxima value of that particular setting. * generate_complete_filename_list(): From the file/directory structure written to the `.project_data.yaml` gets only the list of files. * initialize_project_data(): Initializes the `.project_data.yaml` by writing to the file/directory structure of the project with file names as items of a list but directories as dicts again as sub items of a list. * Some other helper methods for some basic operations are also created. Apart from the changes to green_mode.py a method that is added to Utilities.py is: contained_in(): Detects whether the first argument which must be a SourceRange object is contained absolutely inside the other SourceRange object with closed boundaries. Tests are added for each method except the final green_mode() method. coala_quickstart.py: The arguments: * MAX_NUM_OF_OPTIONAL_ARGS_ALLOWED_FOR_GREEN_MODE * MAX_NUM_OF_VALUES_OF_OPTIONAL_ARGS_ALLOWED_FOR_GREEN_MODE are introduced.
- Loading branch information