Skip to content

curly braces linter and comments #188

Closed

Description

@wamserma

The curly braces linter wants a newline after an opening curly brace, not accepting comments there.

Example

if ("P" != "NP") { # what most people expect
    print("Cryptomania is possible")
} else { # what would make a lot of people sad
    print("we live in Algorithmica")
}

lintr output:

R\test.R:7:22: style: Opening curly braces should never go on their own line and should always be followed by a new line.
    if ("P" != "NP") { # what most people expect
                     ^
R\test.R:9:12: style: Opening curly braces should never go on their own line and should always be followed by a new line.
    } else { # what would make a lot of people sad

Activity

  1. fangly commented on Jan 27, 2017

    @fangly
    Contributor

    Another case where open_curly_linter() fails, in my opinion, is with standalone code blocks (without leading if/for/while/repeat):

    withr::with_options(
         list(verbose=TRUE),
         {
             print("hello")
             print("world")
         }
    )
    
  2. mhburle commented on Apr 1, 2018

    @mhburle
    Contributor

    I second @wamserma (almost posted a duplicate to this by accident actually 😛 ).

    In the meantime, I am using

    if ("P" != "NP") {
                                            # what most people expect
        print("Cryptomania is possible")
    } else {
                                            # what would make a lot of people sad
        print("we live in Algorithmica")
    }
    

    and maybe it makes it more readable???

  3. added
    feature
    on Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions