Append leap instructions to instruct user not use Ruby Date class#1752
Conversation
|
I updated my commit to create a separate append file and instruct the user not to use the date class specifically. |
| @@ -0,0 +1,3 @@ | |||
| # Restrictions | |||
|
|
|||
| Create your own implementation rather than using the Date class from the Ruby standard library. | |||
There was a problem hiding this comment.
This might also work:
| Create your own implementation rather than using the Date class from the Ruby standard library. | |
| Avoid using `Date#leap?` from the Standard Library. |
Simpler English, and uses syntax that you would see to reference the exact method.
There was a problem hiding this comment.
Yeah, I like that. Out of curiosity, is standard library supposed to be capitalized in Ruby circles? Google search seems to have search results for it both being capitalized and not capitalized. Generally, standard library doesn't refer to something specifically with that name so I don't see it capitalized typically.
There was a problem hiding this comment.
Probably Ruby standard library is good. The link provides a direct link to the specific thing in the standard library.
There was a problem hiding this comment.
The tests also prevent the user from using the 'gregorian_leap' or 'julian_leap' methods, so I updated it to be 'Avoid using the Date class from the Standard Library.'
There was a problem hiding this comment.
That does not do what you think it does (if you think it prevents the user from using those).
You can see this if you test it, by writing this code in the example.rb file, and run rake test:leap:
def leap?
Date.gregorian_leap?(number)
endI always thought it was just there to be informative to the reader, but never thought it was meant to be "effective code".
There are trivial ways to get around it, even if it might work in certain circumstances.
There was a problem hiding this comment.
What I would suggest doing, I think, is to leave the advice to the analyzer, and suggest to not use Date#leap? explicitly here.
There was a problem hiding this comment.
I updated my commit to what you suggested earlier.
|
It seems the OS for the CI needs to be bumped in a separate PR. Ubuntu 20.04 hasn't been supported by GHA for about a month so it should be bumped to 22.04 or 24.04. |
kotp
left a comment
There was a problem hiding this comment.
I will approve it, but consider the case of "Standard Library" and make a judgement call to leave it or change it to Standard library or standard library. I think the Core and Standard libraries may be title cased as they are the names given to each library, collection of classes and modules, in Ruby that are supplied when installed.
|
This docs site uses title case, so I will go with that. https://docs.ruby-lang.org/en/3.3/standard_library_rdoc.html |
The discussion in #1532 called for appending the instructions for leap to instruct the user not to use the Date class in Ruby.
Discussion on forums is: Append Ruby leap instructions to instruct user not use Date class.