lint icon indicating copy to clipboard operation
lint copied to clipboard

`styles.assignment.notinfcall` and functions like `system.time`, `within`, `local`

Open flodel opened this issue 12 years ago • 1 comments

This may be related to halpo's issue #5.

system.time, within, local are some of R's function where using assignments inside the arguments are perfectly ok, e.g:

GOOD

system.time(a <- sleep(1))

BAD

system.time(a = sleep(1))

GOOD

within(cars, speed.dist <- speed * dist)

BAD

within(cars, speed.dist = speed * dist)

Would it be possible to modify styles.assignment.notinfcall to handle such exceptions? If not, I would consider removing styles.assignment.notinfcall from lint's default list of tests: lint.style.

flodel avatar Aug 31 '12 18:08 flodel

I'll consider this as a change to the function call region finder but that is something that I am already working on. Too deep of nesting with things like system.time and within are something that I generally frown upon. Within in fact wreaks havoc on the R checker and so should in most cases be avoided in production code.

As far a the default list style list that is not going to change and I highly encourage people to create their own style guides or adopt the published style guides that are already out there. I am loosely guiding my style development off Google and Hadley's style guides.

halpo avatar Sep 04 '12 16:09 halpo