Skip to content
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

Merged
merged 1 commit into from
Mar 6, 2017
Merged

FormatRBear.py: disable parameter-options #1335

merged 1 commit into from
Mar 6, 2017

Conversation

yogupta
Copy link
Contributor

@yogupta yogupta commented Jan 21, 2017

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

@gitmate-bot
Copy link
Collaborator

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!

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))

Copy link
Collaborator

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.

'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))
Copy link
Collaborator

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.

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))

Copy link
Collaborator

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

'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))
Copy link
Collaborator

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:

'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))
Copy link
Collaborator

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.

@gitmate-bot
Copy link
Collaborator

Comment on b00f3bd.

Body of HEAD commit contains too long lines. Commit body lines should not exceed 72 characters.

GitCommitBear, severity NORMAL, section commit.

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))

Copy link
Collaborator

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

@gitmate-bot
Copy link
Collaborator

Comment on b00f3bd.

Shortlog of HEAD commit does not match given regex: ([^:]|[^:]+: [A-Z0-9].*)

GitCommitBear, severity NORMAL, section commit.

@gitmate-bot
Copy link
Collaborator

Comment on a4de771.

Shortlog of HEAD commit does not match given regex: ([^:]|[^:]+: [A-Z0-9].*)

GitCommitBear, severity NORMAL, section commit.

@Udayan12167
Copy link
Contributor

Hey your shortlog is greater than 50 characters try shortening it.

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))
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

@pratyushprakash pratyushprakash Jan 21, 2017

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.

Copy link
Contributor Author

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.

Copy link
Member

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!")}

Copy link
Member

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 ?

r_keep_comments: bool=None,
r_keep_blank_lines: bool=None,
r_braces_on_next_line: bool=None,
r_use_arrows: bool=None,
Copy link
Contributor

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.

Copy link
Contributor Author

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(=) .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

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).

@pratyushprakash
Copy link
Contributor

@IncorrectUsername Could you add tests for this ?

@yogupta
Copy link
Contributor Author

yogupta commented Jan 23, 2017

@pratyushprakash I'm sorry . I could not add tests , I'm getting error Rscript is not installed :(

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@@ -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',
Copy link
Collaborator

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.

@@ -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)
Copy link
Collaborator

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',


FormatRBearDefaultSettingsTest = verify_local_bear(
FormatRBear,
valid_files=(good_file_7,good_file_4),
Copy link
Collaborator

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'})

FormatRBear,
valid_files=(good_file_7, good_file_4),
invalid_files=(bad_file_3,),
settings={'r_keep_blank_lines': 'true'})
Copy link
Member

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)

@Makman2
Copy link
Member

Makman2 commented Feb 15, 2017

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)

@yogupta
Copy link
Contributor Author

yogupta commented Feb 16, 2017

@Makman2 after installing image on docker and running py.test -k FormatRBearTest the tests are skipping.

@Makman2
Copy link
Member

Makman2 commented Feb 16, 2017

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?

@yogupta
Copy link
Contributor Author

yogupta commented Feb 19, 2017

@Makman2 I followed your steps and the tests for the FormatRBearTest passed. check it here asciinema. but still circle is failing.:(

and then when i ran only py.test the tests were failing for other modules.

@Makman2
Copy link
Member

Makman2 commented Feb 20, 2017

rebase and repush, maybe it's a temporary issue^^

@nemani
Copy link
Member

nemani commented Feb 27, 2017

@Makman2 Can you restart the travis?
Feels a bit weird failing on one version of python.

@Makman2
Copy link
Member

Makman2 commented Feb 27, 2017

build restarted 👍

@supergr35
Copy link
Member

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. :)

@Makman2
Copy link
Member

Makman2 commented Mar 1, 2017

ack ba0c25c

@Makman2
Copy link
Member

Makman2 commented Mar 1, 2017

rebase and lgtm ;)

@Makman2
Copy link
Member

Makman2 commented Mar 2, 2017

reack c8810e3

Default options of r_braces_on_next_line,
r_use_arrows are disabled.

Closes #514
@jayvdb
Copy link
Member

jayvdb commented Mar 6, 2017

reack ae985fd

@jayvdb
Copy link
Member

jayvdb commented Mar 6, 2017

@rultor merge

@rultor
Copy link

rultor commented Mar 6, 2017

@rultor merge

@jayvdb OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit ae985fd into coala:master Mar 6, 2017
@rultor
Copy link

rultor commented Mar 6, 2017

@rultor merge

@jayvdb Done! FYI, the full log is here (took me 2min)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

FormatRBear: Allow to disable parameter-options for formatR