active_fedora icon indicating copy to clipboard operation
active_fedora copied to clipboard

rake_support is wack: should require SolrWrapper, FcrepoWrapper, be a Module (or helper, or tasks)

Open atz opened this issue 9 years ago • 3 comments

The file is just a bunch of methods, not a Class or Module.

It invokes SolrWrapper and FcrepoWrapper without requiring those gems.

https://github.com/projecthydra/active_fedora/blob/v11.0.1/lib/active_fedora/rake_support.rb#L17-L32

It also includes a boolean conditional based on a ENV variable string value.
https://github.com/projecthydra/active_fedora/blob/v11.0.1/lib/active_fedora/rake_support.rb#L8-L10

Here's some IRB showing why that is broken:

> puts "foo" if 'false'
(irb):1: warning: string literal in condition
foo
 => nil 
> puts "foo" if 'true'
(irb):2: warning: string literal in condition
foo

Basically, ENV["#{environment}_SERVER_STARTED"] = 'false' does not affect the execution in the way the author expected. For the purposes of the conditional, it is the same as doing nothing.

atz avatar Dec 06 '16 23:12 atz

And what does private mean in a non-class non-module position? https://github.com/samvera/active_fedora/blob/v11.0.1/lib/active_fedora/rake_support.rb#L36

Is the author trying to do OO or not?

atz avatar May 31 '17 22:05 atz

The current code prevents a dependency on solr_wrapper and fcrepo_wrapper in production

jcoyne avatar Jun 01 '17 00:06 jcoyne

We never set 'false' its working because it's effectively doing a nil check

jcoyne avatar Jun 01 '17 00:06 jcoyne