-
Notifications
You must be signed in to change notification settings - Fork 580
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
FormatRBear.py: disable parameter-options #1335
Conversation
Thanks for your contribution! Reviewing pull requests take really a lot of time and we're all volunteers. Please make sure you go through the following check list and complete them all before pinging someone for a review.
As you learn things over your Pull Request please help others on the chat and on PRs to get their stuff right as well! |
bears/r/FormatRBear.py
Outdated
options.add('comment=' + _map_to_r_bool(r_keep_comments)) | ||
if r_use_arrows is not None: | ||
options.add('arrow=' + _map_to_r_bool(r_use_arrows)) | ||
|
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.
W293 blank line contains whitespace'
PycodestyleBear (W293), severity NORMAL, section autopep8
.
bears/r/FormatRBear.py
Outdated
'indent=' + str(indent_size)} | ||
if r_max_expression_length: | ||
options.add('width.cutoff=' + str(r_max_expression_length)) | ||
|
||
if r_braces_on_next_line is not None: | ||
options.add('brace.newline=' + _map_to_r_bool(r_braces_on_next_line)) |
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.
E501 line too long (81 > 79 characters)'
PycodestyleBear (E501), severity NORMAL, section autopep8
.
bears/r/FormatRBear.py
Outdated
options.add('comment=' + _map_to_r_bool(r_keep_comments)) | ||
if r_use_arrows is not None: | ||
options.add('arrow=' + _map_to_r_bool(r_use_arrows)) | ||
|
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.
PEP8Bear, severity NORMAL, section autopep8
.
The issue can be fixed by applying the following patch:
--- a/bears/r/FormatRBear.py
+++ b/bears/r/FormatRBear.py
@@ -89,7 +89,7 @@
options.add('comment=' + _map_to_r_bool(r_keep_comments))
if r_use_arrows is not None:
options.add('arrow=' + _map_to_r_bool(r_use_arrows))
-
+
rcode = 'library(formatR);formatR::tidy_source({})'.format(
','.join(options))
return '-e', rcode
bears/r/FormatRBear.py
Outdated
'indent=' + str(indent_size)} | ||
if r_max_expression_length: | ||
options.add('width.cutoff=' + str(r_max_expression_length)) | ||
|
||
if r_braces_on_next_line is not None: | ||
options.add('brace.newline=' + _map_to_r_bool(r_braces_on_next_line)) |
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.
PEP8Bear, severity NORMAL, section autopep8
.
The issue can be fixed by applying the following patch:
--- a/bears/r/FormatRBear.py
+++ b/bears/r/FormatRBear.py
@@ -82,7 +82,8 @@
if r_max_expression_length:
options.add('width.cutoff=' + str(r_max_expression_length))
if r_braces_on_next_line is not None:
- options.add('brace.newline=' + _map_to_r_bool(r_braces_on_next_line))
+ options.add('brace.newline=' +
+ _map_to_r_bool(r_braces_on_next_line))
if r_keep_blank_lines is not None:
options.add('blank=' + _map_to_r_bool(r_keep_blank_lines))
if r_keep_comments is not None:
bears/r/FormatRBear.py
Outdated
'indent=' + str(indent_size)} | ||
if r_max_expression_length: | ||
options.add('width.cutoff=' + str(r_max_expression_length)) | ||
|
||
if r_braces_on_next_line is not None: | ||
options.add('brace.newline=' + _map_to_r_bool(r_braces_on_next_line)) |
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.
Line is longer than allowed. (81 > 79)
LineLengthBear, severity NORMAL, section linelength
.
Comment on b00f3bd. Body of HEAD commit contains too long lines. Commit body lines should not exceed 72 characters. GitCommitBear, severity NORMAL, section |
bears/r/FormatRBear.py
Outdated
options.add('comment=' + _map_to_r_bool(r_keep_comments)) | ||
if r_use_arrows is not None: | ||
options.add('arrow=' + _map_to_r_bool(r_use_arrows)) | ||
|
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.
Line contains following spacing inconsistencies:
- Trailing whitespaces.
SpaceConsistencyBear, severity NORMAL, section python
.
The issue can be fixed by applying the following patch:
--- a/bears/r/FormatRBear.py
+++ b/bears/r/FormatRBear.py
@@ -89,7 +89,7 @@
options.add('comment=' + _map_to_r_bool(r_keep_comments))
if r_use_arrows is not None:
options.add('arrow=' + _map_to_r_bool(r_use_arrows))
-
+
rcode = 'library(formatR);formatR::tidy_source({})'.format(
','.join(options))
return '-e', rcode
Comment on b00f3bd. Shortlog of HEAD commit does not match given regex: ([^:]|[^:]+: [A-Z0-9].*) GitCommitBear, severity NORMAL, section |
Comment on a4de771. Shortlog of HEAD commit does not match given regex: ([^:]|[^:]+: [A-Z0-9].*) GitCommitBear, severity NORMAL, section |
Hey your shortlog is greater than 50 characters try shortening it. |
bears/r/FormatRBear.py
Outdated
if r_keep_comments is not None: | ||
options.add('comment=' + _map_to_r_bool(r_keep_comments)) | ||
if r_use_arrows is not None: | ||
options.add('arrow=' + _map_to_r_bool(r_use_arrows)) |
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 think is not None
is redundant 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.
Same logic goes here also . user may have used both =
and ->
. if it doesn't check is not None
then it will skip if
statement.
Suppose user provided False
value.then it will skip if
and the values won't effect the code.
Correct me if i'm wrong
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.
In this case both True
and False
will add the option
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.
if i keep it None
while declaring then , False
value will never add up into options
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.
@IncorrectUsername If r_keep_comments
is set to False
in settings the line options.add('comment=' + _map_to_r_bool(r_keep_comments))
will be executed.
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.
Yes , it will be executed.
I was saying that if you don't provide value in settings then it won't be executed.
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 am just wondering ( i don't have formtR installled )
what is wrong with this piece of code given that all of the settings have been disabled
1+1
if(TRUE){
x=1 # inline comments
}else{x=2;print("Oh no... ask the right bracket to go away!")}
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.
Unless i am not getting this wrong @Makman2, but the problem here is that these settings are too specific right, and we want the user to enable them manualy, given that the file above is not correct, then something is not right @IncorrectUsername, check on that would you ?
bears/r/FormatRBear.py
Outdated
r_keep_comments: bool=None, | ||
r_keep_blank_lines: bool=None, | ||
r_braces_on_next_line: bool=None, | ||
r_use_arrows: bool=None, |
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.
This should be False
instead of None
.
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.
If it is False then ,suppose for eg: r_use_arrows=false then there will be no arrows everything will be equal(=
) .
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.
It was right (using None
). The original issue of this PR is making FormatRBear ignore those option. Meaning they dont enforce using arrow (True
) neither never user arrow (False
).
@IncorrectUsername Could you add tests for this ? |
@pratyushprakash I'm sorry . I could not add tests , I'm getting error |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
bears/haskell/GhcModBear.py
Outdated
@@ -1,7 +1,8 @@ | |||
from coalib.bearlib.abstractions.Linter import linter | |||
from dependency_management.requirements.CabalRequirement import ( | |||
CabalRequirement) | |||
|
|||
from dependency_management.requirements.DistributionRequirement import ( | |||
DistributionRequirement) | |||
|
|||
@linter(executable='ghc-mod', |
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'
PycodestyleBear (E302), severity NORMAL, section autopep8
.
bears/haskell/GhcModBear.py
Outdated
@@ -1,7 +1,8 @@ | |||
from coalib.bearlib.abstractions.Linter import linter | |||
from dependency_management.requirements.CabalRequirement import ( | |||
CabalRequirement) | |||
|
|||
from dependency_management.requirements.DistributionRequirement import ( | |||
DistributionRequirement) |
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.
PEP8Bear, severity NORMAL, section autopep8
.
The issue can be fixed by applying the following patch:
--- a/bears/haskell/GhcModBear.py
+++ b/bears/haskell/GhcModBear.py
@@ -3,6 +3,7 @@
CabalRequirement)
from dependency_management.requirements.DistributionRequirement import (
DistributionRequirement)
+
@linter(executable='ghc-mod',
output_format='regex',
tests/r/FormatRBearTest.py
Outdated
|
||
FormatRBearDefaultSettingsTest = verify_local_bear( | ||
FormatRBear, | ||
valid_files=(good_file_7,good_file_4), |
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.
PEP8Bear, severity NORMAL, section autopep8
.
The issue can be fixed by applying the following patch:
--- a/tests/r/FormatRBearTest.py
+++ b/tests/r/FormatRBearTest.py
@@ -142,6 +142,6 @@
FormatRBearDefaultSettingsTest = verify_local_bear(
FormatRBear,
- valid_files=(good_file_7,good_file_4),
+ valid_files=(good_file_7, good_file_4),
invalid_files=(bad_file_3,),
settings={'r_keep_blank_lines': 'true'})
tests/r/FormatRBearTest.py
Outdated
FormatRBear, | ||
valid_files=(good_file_7, good_file_4), | ||
invalid_files=(bad_file_3,), | ||
settings={'r_keep_blank_lines': '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.
as it's a default test, you maybe want to omit settings
^^ (especially r_keep_blank_lines
doesn't do anything in fact :3)
Hm seems tests are still failing, did you try them locally? (If you don't want to install R and anything needed for coala, you can grab our latest docker image) |
@Makman2 after installing image on docker and running |
Tests do not skip for me, and when I checkout your branch I get the same error like in the CI. Did you run the command in the container actually? |
rebase and repush, maybe it's a temporary issue^^ |
@Makman2 Can you restart the travis? |
build restarted 👍 |
By the way, advice for the future: Please don't develop on the master branch. It can create some problems down the line, and we develop on other branches. If you don't know how check the git basics documentation. :) |
ack ba0c25c |
rebase and lgtm ;) |
reack c8810e3 |
Default options of r_braces_on_next_line, r_use_arrows are disabled. Closes #514
reack ae985fd |
@rultor merge |
r_keep_comments,r_keep_blank_lines,r_braces_on_next_line,r_use_arrows are
disabled and will not be checked untill the user provides value.
closes #514