rake icon indicating copy to clipboard operation
rake copied to clipboard

chore: simplify `Rake::Application#system_dir` method

Open pvdb opened this issue 4 months ago • 0 comments

Due to it being a tad convoluted, it took me longer than it probably should have to grok what the Rake::Application#system_dir method was trying to do.

I think this simplification makes it a lot more obvious, especially as the same ...

hash[:lookup_key] || :default_value

... idiom is already used elsewhere in the rake codebase.

It also avoids a double hash lookup: one lookup to see if RAKE_SYSTEM is set in the ENV hash, and - if it is - exactly the same lookup again to actually fetch its value. 🎉

PS - I was tempted to also include the following change in this PR ... happy to take your steer @hsbt : include it in this one, or issue a separate PR instead? (or else forget about it altogether if it's totally bonkers?) 😅

--- a/lib/rake/application.rb
+++ b/lib/rake/application.rb
@@ -765,7 +765,7 @@ module Rake
       end
     else
       def standard_system_dir #:nodoc:
-        File.join(File.expand_path("~"), ".rake")
+        File.join(Dir.home, ".rake")
       end
     end
     private :standard_system_dir

pvdb avatar Oct 02 '24 08:10 pvdb