Skip to content

lint formals and ensure names match >= 1 style - #398

Merged
russHyde merged 2 commits into
r-lib:name_performancefrom
russHyde:name_performance2
Aug 23, 2019
Merged

russHyde merged 2 commits into
r-lib:name_performancefrom
russHyde:name_performance2

Conversation

@russHyde

Copy link
Copy Markdown
Collaborator

Previous xml-based version of object_name_linter:

  • required all names to match every one of the requested
    styles

  • disregarded names of formals in newly-defined functions

Hence:

  • added extra xpath clause to catch SYMBOL_FORMALS

  • used or-reduction to ensure each name matches at least one
    style.

Also:

  • since multiple styles are allowed, the lint message is now
    like "Variable and function name style should be style_1,
    style_2 or style_3".

  • tests for object_name_linter and lint message for
    object_name_linter_old were changed to match this
    format.

  • added ... argument to a unit test to ensure that
    object_name_linter does not flag dots.

Previous xml-based version of object_name_linter:

- required all names to match every one of the requested
  styles

- disregarded names of formals in newly-defined functions

Hence:

- added extra xpath clause to catch SYMBOL_FORMALS

- used or-reduction to ensure each name matches at least one
style.

Also:

- since multiple styles are allowed, the lint message is now
  like "Variable and function name style should be style_1,
  style_2 or style_3".

- tests for `object_name_linter` and lint message for
  `object_name_linter_old` were changed to match this
  format.

- added `...` argument to a unit test to ensure that
  `object_name_linter` does not flag dots.
@russHyde
russHyde requested a review from jimhester as a code owner August 22, 2019 13:12
@codecov

codecov Bot commented Aug 22, 2019 •

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (name_performance@e806f96). Click here to learn what that means.
The diff coverage is 96%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##             name_performance     #398   +/-   ##
===================================================
  Coverage                    ?   81.57%           
===================================================
  Files                       ?       43           
  Lines                       ?     1954           
  Branches                    ?        0           
===================================================
  Hits                        ?     1594           
  Misses                      ?      360           
  Partials                    ?        0
Impacted Files Coverage Δ
R/object_name_linters.R 84.92% <96%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e806f96...e601786. Read the comment docs.

@russHyde

russHyde commented Aug 22, 2019 •

Copy link
Copy Markdown
Collaborator Author

sorry - forgot the docs. Updated.

Added UTF-8 encoding to DESCRIPTION to get roxygen to
compile the docs
@russHyde
russHyde merged commit c97b238 into r-lib:name_performance Aug 23, 2019
@russHyde
russHyde deleted the name_performance2 branch August 23, 2019 15:08
russHyde pushed a commit that referenced this pull request Aug 23, 2019
* Re-implementation of object_name_linter

Is both more robust and an order of magnitude more performant

    microbenchmark(
      {lint("R/lint.R", object_name_linter("snake_case"))},
      {lint("R/lint.R", object_name_linter_old("snake_case"))})
    #> Unit: milliseconds
    #>                                                         expr       min        lq      mean    median        uq      max neval
    #>  {     lint("R/lint.R", object_name_linter2("snake_case")) }  225.9701  252.2269  265.9434  263.2129  273.7824  483.367   100
    #>   {     lint("R/lint.R", object_name_linter("snake_case")) } 1275.5349 1360.3626 1430.6543 1425.3408 1486.9745 1735.298   100

* Prevent crash following NAMESPACE not found

* Use existing pkg_name() function

* Don't assume that user is in package root

In namespace_import, use package root by default instead of current directory

* Add missing file

* Fix issues when object_name_linter has compound assignments with `$` and `@`.

* Fixed failing example and incomplete line warning

* Fixed mismatch between code and documentation

* lint formals and ensure names match >= 1 style (#398)

* lint formals and ensure names match >= 1 style

Previous xml-based version of object_name_linter:

- required all names to match every one of the requested
  styles

- disregarded names of formals in newly-defined functions

Hence:

- added extra xpath clause to catch SYMBOL_FORMALS

- used or-reduction to ensure each name matches at least one
style.

Also:

- since multiple styles are allowed, the lint message is now
  like "Variable and function name style should be style_1,
  style_2 or style_3".

- tests for `object_name_linter` and lint message for
  `object_name_linter_old` were changed to match this
  format.

- added `...` argument to a unit test to ensure that
  `object_name_linter` does not flag dots.

* change docs to reflect use of >= 1 style

Added UTF-8 encoding to DESCRIPTION to get roxygen to
compile the docs
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

Successfully merging this pull request may close these issues.

1 participant