Add docs on writing aspect bear #4666
Conversation
https://github.com/coala/cEPs/blob/master/cEP-0005.md. | ||
|
||
An aspect-compliant bear MUST: | ||
1. Declare list of aspect it can fix and detected. Note that the aspect MUST be |
adhikasp
Aug 24, 2017
Author
Member
Blank line here
Blank line here
3. Map setting to its equivalent aspect or taste using ``map_setting_to_aspect`` | ||
decorator. | ||
4. Anotate yielded result with ``aspect``. | ||
|
hemangsk
Aug 24, 2017
Member
Annotate*
Annotate*
""" | ||
Override function arguments value with coala's aspect and taste. | ||
|
||
This decorators could be used by ``Bear.run()`` to automatically map and |
hemangsk
Aug 24, 2017
Member
Suggestion: decorator can* might be better
Suggestion: decorator can* might be better
it looks good to me |
This is waiting on #4662 |
def run(self, | ||
filename, | ||
file, | ||
use_standard_dictionary:bool=True, |
jayvdb
Aug 27, 2017
Member
We typically have a space after :
, which is the general style at https://www.python.org/dev/peps/pep-0484/
We typically have a space after :
, which is the general style at https://www.python.org/dev/peps/pep-0484/
languages=['Python']): | ||
|
||
@map_setting_to_aspect( | ||
use_standard_dictionary=DictionarySpelling |
jayvdb
Aug 27, 2017
Member
comma not needed here??
please run your sample code through linters.
comma not needed here??
please run your sample code through linters.
class SpellingCheckBear( | ||
LocalBear, | ||
aspect={ | ||
'detect': [DictionarySpelling, OrgSpecificWordSpelling] |
jayvdb
Aug 27, 2017
Member
trailing comma
trailing comma
if word not in dictionary_words: | ||
yield self.new_result( | ||
message='Wrong spelling', | ||
additional_info=(DictionarySpelling.docs |
jayvdb
Aug 27, 2017
Member
shouldnt DictionarySpelling.docs.importance_reason
be the default value for additional_info
?
shouldnt DictionarySpelling.docs.importance_reason
be the default value for additional_info
?
adhikasp
Aug 27, 2017
Author
Member
Yes it should be. If you mean
If result have aspect
arg, it should be defaulting to use aspect.docs.importance_reason
then, no, it is not implemented yet.
Yes it should be. If you mean
If result have
aspect
arg, it should be defaulting to useaspect.docs.importance_reason
then, no, it is not implemented yet.
jayvdb
Aug 27, 2017
Member
Is there a bug about it?! If not, please create one!
This would fall in your main project scope, of making it easy to use aspects.
Is there a bug about it?! If not, please create one!
This would fall in your main project scope, of making it easy to use aspects.
adhikasp
Aug 27, 2017
Author
Member
That issue is included in this PR too.
That issue is included in this PR too.
for word in file.split(): | ||
if word not in dictionary_words: | ||
yield self.new_result( | ||
message='Wrong spelling', |
jayvdb
Aug 27, 2017
Member
this message should include the value of word
this message should include the value of word
# Imagine this is where we save our standard dictionary. | ||
dictionary_words = ['lorem', 'ipsum'] | ||
|
||
if not use_standard_dictionary: |
jayvdb
Aug 27, 2017
Member
this logic is tortured.
use
if ...:
dictionary_words = ['lorem', 'ipsum']
else:
dictionary_words = []
this logic is tortured.
use
if ...:
dictionary_words = ['lorem', 'ipsum']
else:
dictionary_words = []
Contain additional commit to fix #4682 |
not tested properly. |
ack d41d691 |
rebase and LGTM |
Relates to #4665
reack 8c9141c |
@rultor merge |
8c9141c
into
coala:master
Relates to #4665
Contain commit from #4662