Skip to content

Comments in if clause without braces not recognised correctly #278

Closed

Description

@lorenzwalthert
reprex::reprex_info()
#> Created by the reprex package v0.1.1.9000 on 2017-11-08

  styler::style_text(
"if (!inherits(geom, 'Geom')) # for geoms that return more than one thing
  a()
")
#> Error in if (has_if_without_curly) {: missing value where TRUE/FALSE needed

Need to make consistent use of next_non_comment() to find correct positions.

Activity

  1. added this to the milestone on Nov 8, 2017
  2. krlmlr commented on Nov 12, 2017

    @krlmlr
    Member

    This looks like a lot of work -- do we need to review all transformers?

    I'd like to suggest the following:

    • Fix this problem (and any others we might encounter before CRAN release)
    • Set the default scope to "line_breaks"
    • After transformation, verify that styling hasn't changed the results:
      identical(parse(text = "a+1"), parse(text = "a + 1"))
      #> [1] TRUE
    • Only warn to "check results accurately" for scope > "line_breaks"

    How does that sound?

  3. lorenzwalthert commented on Nov 18, 2017

    @lorenzwalthert
    CollaboratorAuthor

    What makes you think we need to review all transformers? I think line spacing indention transformers are fine, for line break transformers we check that the token before the line break to remove is not a comment so the only ones remaining are the token transformers, which I think, are tricky. I filed #279 which hopefully resolves the issues.

    However, I think you are right in that we may want to parse the result to check for equivalence of the parse data.

    To be on the safe side, yes, we may want to set the default scope to "line_breaks" and add a warning for scope = "tokens"

  4. krlmlr commented on Nov 18, 2017

    @krlmlr
    Member

    Agree that spacing transformers are fine, but it seems we need to double-check transformers that merge lines.

    One more thing: Parse data identity probably needs keep.source = FALSE in the parse() calls.

  5. lorenzwalthert commented on Nov 19, 2017

    @lorenzwalthert
    CollaboratorAuthor

    But keeping the source does not give the desired output. Why do you think we should use keep.source = TRUE

    reprex::reprex_info()
    #> Created by the reprex package v0.1.1.9000 on 2017-11-19
    
    identical(parse(text = "a+1", keep.source = TRUE), parse(text = "a + 1", keep.source = TRUE))
    #> [1] FALSE
  6. krlmlr commented on Nov 19, 2017

    @krlmlr
    Member

    I thought we should use keep.source = FALSE .

  7. lorenzwalthert commented on Nov 19, 2017

    @lorenzwalthert
    CollaboratorAuthor

    ugh right...

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions