-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tillgreenmodecore #288
Tillgreenmodecore #288
Conversation
import os | ||
|
||
from coala_quickstart.green_mode.green_mode import (initialize_project_data, | ||
dump_to_file, get_contents,run_quickstartbear, bear_test_fun) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code does not comply to PEP8.
Origin: PEP8Bear, Section: all.autopep8
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmp8k30bh87/coala_quickstart/green_mode/green_mode_core.py
+++ b/tmp/tmp8k30bh87/coala_quickstart/green_mode/green_mode_core.py
@@ -1,9 +1,10 @@
import os
from coala_quickstart.green_mode.green_mode import (initialize_project_data,
- dump_to_file, get_contents,run_quickstartbear, bear_test_fun)
+ dump_to_file, get_contents, run_quickstartbear, bear_test_fun)
from coala_quickstart.green_mode.filename_operations import (
check_filename_prefix_postfix)
+
def green_mode(project_dir, ignore_globs, bears, bear_settings_obj,
op_args_limit, value_to_op_args_limit, printer=None):
import os | ||
|
||
from coala_quickstart.green_mode.green_mode import (initialize_project_data, | ||
dump_to_file, get_contents,run_quickstartbear, bear_test_fun) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E128 continuation line under-indented for visual indent
Origin: PycodestyleBear (E128), Section: all.autopep8
.
import os | ||
|
||
from coala_quickstart.green_mode.green_mode import (initialize_project_data, | ||
dump_to_file, get_contents,run_quickstartbear, bear_test_fun) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E231 missing whitespace after ','
Origin: PycodestyleBear (E231), Section: all.autopep8
.
from coala_quickstart.green_mode.filename_operations import ( | ||
check_filename_prefix_postfix) | ||
|
||
def green_mode(project_dir, ignore_globs, bears, bear_settings_obj, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E302 expected 2 blank lines, found 1
Origin: PycodestyleBear (E302), Section: all.autopep8
.
7fc34a3
to
a715ae7
Compare
Travis tests have failedHey @ishanSrt, 3rd Buildpytest
|
a715ae7
to
e06b9b5
Compare
Travis tests have failedHey @ishanSrt, 3rd Buildpytest
|
Travis tests have failedHey @ishanSrt, |
a106fc3
to
ad4f202
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split your test modules into smaller units as requested at #263 (comment)
each test method has a timer
ad4f202
to
a4e0218
Compare
a4e0218
to
40a266c
Compare
f9c232c
to
979a7a4
Compare
Comment on 979a7a4, file tests/green_mode/green_modeTest.py, line 309. The code does not comply to PEP8. Origin: PEP8Bear, Section: The issue can be fixed by applying the following patch: --- a/tmp/tmpsq3cf1r1/tests/green_mode/green_modeTest.py
+++ b/tmp/tmpsq3cf1r1/tests/green_mode/green_modeTest.py
@@ -306,7 +306,6 @@
self.assertCountEqual(unified_results[0][TestLocalBear],
test_unified_results[0][TestLocalBear])
-
def test_bear_test_fun_2(self):
from pyprint.ConsolePrinter import ConsolePrinter
printer = ConsolePrinter() |
Comment on 979a7a4, file tests/green_mode/green_modeTest.py, line 310. E303 too many blank lines (2) Origin: PycodestyleBear (E303), Section: |
settings_key = 'green_mode_infinite_value_settings' | ||
|
||
|
||
def append_to_contents(contents, key, values): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I will have to add another argument to the function
coala_quickstart/coala_quickstart.py
Outdated
@@ -24,7 +24,11 @@ | |||
from coala_quickstart.generation.Settings import ( | |||
generate_settings, write_coafile) | |||
from coala_quickstart.generation.SettingsClass import ( | |||
collect_bear_settings) | |||
collect_bear_settings, build_bear_settings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont modify this line; b goes before c, alphabetically.
c.f. #288 (comment)
return True | ||
elif len(ignore_ranges) == 0: | ||
return False | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
I don't see any unnecessary else over here
ret_val = bear_obj.run(**dict(zip(kwargs, vals))) | ||
ret_val = list(ret_val) | ||
# FIXME: Multiprocessing not working on windows. | ||
if os.name == 'nt': # pragma: no cover |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use OS specific coverage rules -- see setup.cfg , and see coala/coala for examples
new_data = initialize_project_data(project_dir+os.sep, ignore_globs) | ||
data_to_dump = {'dir_structure': new_data} | ||
dump_yaml_to_file(project_data, data_to_dump) | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else: pass is redundant
ignore_ranges, project_data_contents, file_names, | ||
op_args_limit, value_to_op_args_limit, printer) | ||
|
||
# Call to create `.coafile` goes over here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there supposed to be some code after this, before the next comment ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its in the next commit, (next PR)
if not found: | ||
contents[settings_key].append({setting: value}) | ||
return contents | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary else
if not found: | ||
contents[settings_key].append({setting: value}) | ||
return contents | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecesary else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't get it why is it an unnecessary else?
3b73f09
to
bd63794
Compare
Comment on bd63794, file tests/green_mode/filename_operationsTest.py, line 7. Line contains following spacing inconsistencies:
Origin: SpaceConsistencyBear, Section: The issue can be fixed by applying the following patch: --- a/tmp/tmpy5q2_7ig/tests/green_mode/filename_operationsTest.py
+++ b/tmp/tmpy5q2_7ig/tests/green_mode/filename_operationsTest.py
@@ -4,7 +4,7 @@
from pathlib import Path
from coala_quickstart.generation.Utilities import (
- append_to_contents,
+ append_to_contents,
)
from coala_quickstart.green_mode.filename_operations import (
get_files_list, check_filename_prefix_postfix) |
Comment on bd63794, file tests/green_mode/filename_operationsTest.py, line 8. Line contains following spacing inconsistencies:
Origin: SpaceConsistencyBear, Section: The issue can be fixed by applying the following patch: --- a/tmp/tmpy5q2_7ig/tests/green_mode/filename_operationsTest.py
+++ b/tmp/tmpy5q2_7ig/tests/green_mode/filename_operationsTest.py
@@ -5,7 +5,7 @@
from coala_quickstart.generation.Utilities import (
append_to_contents,
- )
+ )
from coala_quickstart.green_mode.filename_operations import (
get_files_list, check_filename_prefix_postfix)
from coala_quickstart.green_mode.green_mode import ( |
Comment on bd63794, file tests/green_mode/filename_operationsTest.py, line 7. The code does not comply to PEP8. Origin: PEP8Bear, Section: The issue can be fixed by applying the following patch: --- a/tmp/tmpy5q2_7ig/tests/green_mode/filename_operationsTest.py
+++ b/tmp/tmpy5q2_7ig/tests/green_mode/filename_operationsTest.py
@@ -4,8 +4,8 @@
from pathlib import Path
from coala_quickstart.generation.Utilities import (
- append_to_contents,
- )
+ append_to_contents,
+ )
from coala_quickstart.green_mode.filename_operations import (
get_files_list, check_filename_prefix_postfix)
from coala_quickstart.green_mode.green_mode import ( |
Comment on bd63794, file tests/green_mode/filename_operationsTest.py, line 7. W191 indentation contains tabs Origin: PycodestyleBear (W191), Section: |
Comment on bd63794, file tests/green_mode/filename_operationsTest.py, line 8. W191 indentation contains tabs Origin: PycodestyleBear (W191), Section: |
Comment on bd63794, file tests/green_mode/filename_operationsTest.py, line 10. E101 indentation contains mixed spaces and tabs Origin: PycodestyleBear (E101), Section: |
bd63794
to
eb133e6
Compare
return contents | ||
|
||
|
||
def find_min_of_setting(setting, value, contents): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the contents of this function look identical (except for one character) to the above ;-(
- example_file_4 | ||
- example_file_5 | ||
- example_file_6 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the trailing blank lines.
and make sure your yaml passes yamllint
append_to_contents, | ||
) | ||
from coala_quickstart.green_mode.filename_operations import ( | ||
get_files_list, check_filename_prefix_postfix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alpha order
one per line
trailing commas
tests/green_mode/green_modeTest.py
Outdated
from coala_quickstart.generation.SettingsClass import ( | ||
collect_bear_settings) | ||
from coala_quickstart.green_mode.Setting import ( | ||
find_max_of_setting, find_min_of_setting,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
,)
??
tests/green_mode/green_modeTest.py
Outdated
project_data = 'example_.project_data.yaml' | ||
full_path = str(Path(__file__).parent / project_data) | ||
yaml_contents = get_yaml_contents(full_path) | ||
test_yaml_contents = {'dir_structure': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move 'dir_structure':
down to the next line, indented by four spaces from test_y...
and then indent everything else accordingly from there.
tests/green_mode/green_modeTest.py
Outdated
'key', [1, 2], settings_key) | ||
self.assertEqual(ret_contents, {settings_key: | ||
[{'key': [3, 1, 2]}, | ||
{'some_other_key': [True]}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this aligned with ?
tests/green_mode/green_modeTest.py
Outdated
'bear_settings.yaml', | ||
'green_modeTest.py', | ||
'filename_operationsTest.py', | ||
'test_dir'+os.sep+'test_file.py'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaces around +
This file contains functions required to guess settings regarding the names of the files. Tests are added for the same.
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_setting_type(): 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_max_min_of_setting(): Is a helper function for bear settings that runs 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.
eb133e6
to
ffaff5c
Compare
@gitmate-bot ff |
Hey! I'm GitMate.io! This pull request is being fastforwarded automatically. Please DO NOT push while fastforward is in progress or your changes would be lost permanently |
Automated fastforward with GitMate.io was successful! 🎉 |
Thank you @jayvdb with the review 😄 |
No description provided.