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

Check ideas #1

Closed
33 tasks done
gaborcsardi opened this issue Feb 13, 2016 · 18 comments
Closed
33 tasks done

Check ideas #1

gaborcsardi opened this issue Feb 13, 2016 · 18 comments

Comments

@gaborcsardi
Copy link
Collaborator

gaborcsardi commented Feb 13, 2016

DESCRIPTION file

  • URL
  • BugReports
  • No Depends
  • No Date
  • Valid fields (R CMD check does most of this) R CMD check does it
  • No whitespace from DESCRIPTION field names R CMD check does it
  • No blank lines from DESCRIPTION R CMD check does it

NAMESPACE file

Code complexity

S4

Functions to avoid

  • attach
  • setwd
  • sapply
  • library/require

Expressions to avoid

  • 1:length(x)

Packages to avoid

Documentation

Tests

Code style

  • Conforms to a standard Hard to check in general, so closing now.

R CMD check

  • Report all problems
@HenrikBengtsson
Copy link

@gaborcsardi
Copy link
Collaborator Author

@HenrikBengtsson Looks great, thanks! goodpractice will definitely have flavours, actually it already has something, I called it "styles", flavour is a better word I think.

@HenrikBengtsson
Copy link

BTW, is your check list in top box suggestion it is bad to specify Date: in your DESCRIPTION, cf. "No Date"?

@gaborcsardi
Copy link
Collaborator Author

YEs, it is bad to specify Date, that's what I meant.

@HenrikBengtsson
Copy link

Why?

@gaborcsardi
Copy link
Collaborator Author

Goes out of date often because people don't update it, and it is not a required field. Another date field is put in automatically by R CMD build.

But again, this is subjective, and in your flavour you can turn it on and off as you like.

@HenrikBengtsson
Copy link

Goes out of date often because people don't update it, and it is not a required field.

Yes, I agree outdated Date: info is useless. Recently(?), R CMD check --as-cran started to report on this:

* checking CRAN incoming feasibility ... NOTE
Maintainer: 'John Doe <johndoe@example.com>'
The Date field is over a month old.
* checking package namespace information ... OK

Another date field is put in automatically by R CMD build.

True, but on the other hand the Packaged: field also change whenever the otherwise identical source is rebuilt.

I was mostly curious on your take on this, so nothing important to me. I like to be able to see when a package was "touched" by the developer (info that should be self contained). The Date: field provides that info if maintained. An alternative, which I actually prefer, is that the NEWS file provides a date with every version entry. This gives further information how old "old" is, because the perception of time varies widely between version numbering formats and developers. Unfortunately, not all packages provide dates in NEWS.

I'm experimenting moving away from Date: in some of my packages and only keeping that info in NEWS. The reason for that is mostly to save me a few keystrokes having to update Date:.

@peterhurford
Copy link

I'd really like to see a linter that goes through all the functions in your package and ensures that (1) they are prefixed and that (2) they are declared in your DESCRIPTION file. Also should ensure there are no library or require calls. I don't know if lintr or R CMD CHECK does that already?

@gaborcsardi
Copy link
Collaborator Author

@peterhurford library() and require calls are picked up by R CMD check, so we get those automatically.

What do you mean about functions being prefixed? Can you give an example?

I am also not sure about declaring functions in DESCRIPTION. You mean packages, maybe?

@peterhurford
Copy link

@gaborcsardi

library() and require calls are picked up by R CMD check, so we get those automatically.

Ah, awesome. 👍

What do you mean about functions being prefixed? Can you give an example?

Like making sure you call goodpractice::gp instead of gp from within your package. I think this may already be covered by R CMD CHECK.

I am also not sure about declaring functions in DESCRIPTION. You mean packages, maybe?

Haha, yeah, I meant packages.

@gaborcsardi
Copy link
Collaborator Author

Like making sure you call goodpractice::gp instead of gp from within your package. I think this may already be covered by R CMD CHECK.

That is not strictly compulsory if you import the function via NAMESPACE. (Or the whole package, although that is not suggested.) But it is true that explicit calls can be a legitimate requirement, and then we can check for this, yes. I'll add it above.

Haha, yeah, I meant packages.

That is checked by R CMD check, too, I think.

@peterhurford
Copy link

Came here to suggest you check for code coverage, but I see you already have that. 👍

Other idea: any plan to integrate with https://github.com/jimhester/lintr?

@gaborcsardi
Copy link
Collaborator Author

Yes, we will call lintr as well.

@drisso
Copy link

drisso commented Jun 30, 2016

Bioconductor has the BiocCheck package that performs some useful checks (here: https://github.com/Bioconductor/BiocCheck).
A lot of Bioconductor specific checks not relevant here, but some useful, like check direct slot access for S4 objects, use of <<- and browser().

@gaborcsardi
Copy link
Collaborator Author

@drisso 👍

@eribul
Copy link

eribul commented Jul 8, 2016

Not sure I like this advice my self (I don't follow it so far ...) but I recently picked up (through discussion during UseR2016) that the use of x$y is considered bad practice for non interactive use, where x[["y"]] should actually be preffered.

One reason is motivated by the following (as stated by Hadley):

> a <- data.frame(xyz = 1)
> a$x
[1] 1
> a[["x"]]
NULL
> 

@gaborcsardi
Copy link
Collaborator Author

@eribul R CMD check already catches partial names IMO, so we have that already I think. Let me know if we don't catch it.

@gaborcsardi
Copy link
Collaborator Author

Closing this now. I opened separate issues for the remaining ones.

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

No branches or pull requests

5 participants