DEV Community

RobL
RobL

Posted on

Warnings / I just live here

I remember distinctly returning home to our flat and finding what can only be described as something horrible all over the front door of the shared entrance. We armed ourselves with rubber gloves, bleach, and a bucket and set about cleaning it up. As we did another person who lived in the block walked and said 'oh, yes I saw that. But I just live here' and wandered off.

I just live here. Well, so do we. We all live and breath our code and we are the caretakers of it. We like to check in on it from time to time. And we should listen to it.

Sometimes it's trying to tell us something. I know we're told to often keep our tickets / tasks limited to the task at hand and don't go off on a wild goose chase to Rubocop every single file in the application when you were only supposed to bump a gem version. But everytime we do a piece of work, it's not a bad idea to go in a fix the things our application is complaining about. Hell. Many of them tell you exactly how to fix them.

Today I saw this and we can all do with a world with less noise.

Randomized with seed 11034
.................************************************************************************
Warning from shoulda-matchers:

The `with` qualifier on `define_enum_for` is deprecated and will be
removed in the next major release. Please use `with_values` instead.
************************************************************************
.************************************************************************
Warning from shoulda-matchers:

The `with` qualifier on `define_enum_for` is deprecated and will be
removed in the next major release. Please use `with_values` instead.
************************************************************************
......................************************************************************************
Warning from shoulda-matchers:

The `with` qualifier on `define_enum_for` is deprecated and will be
removed in the next major release. Please use `with_values` instead.
************************************************************************
...........

/Users/rl/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/faker-2.22.0/lib/helpers/unique_generator.rb:21: Passing `number` with the 1st argument of `alphanumeric` is deprecated. Use keyword argument like `alphanumeric(number: ...)` instead.

To automatically update from positional arguments to keyword arguments,
install rubocop-faker and run:

rubocop \
  --require rubocop-faker \
  --only Faker/DeprecatedArguments \
  --auto-correct

Finished in 4.41 seconds (files took 10.26 seconds to load)
51 examples, 0 failures
Enter fullscreen mode Exit fullscreen mode

This is easily fixed, and no one was hurt in the process.

diff --git a/lib/blah/factories/some_model_or_something.rb b/lib/blah/factories/some_model_or_something.rb
index 65ccf6e..58752f8 100644
--- a/lib/blah/factories/some_model_or_something.rb
+++ b/lib/blah/factories/some_model_or_something.rb
@@ -2,7 +2,7 @@

 FactoryBot.define do
   factory :some_model_or_something do
-    name { Faker::Alphanumeric.unique.alphanumeric(7) }
+    name { Faker::Alphanumeric.unique.alphanumeric(number: 7) }
     categories { FactoryBot.create_list(:some_model_or_something, 1) }
     parent_id { nil }
   end

diff --git a/spec/models/some_model_or_something_spec.rb b/spec/models/some_model_or_something_spec.rb
index cec65ff..007a77a 100644
--- a/spec/models/some_model_or_something_spec.rb
+++ b/spec/models/some_model_or_something_spec.rb
@@ -34,14 +34,14 @@ RSpec.describe SomeModelOrSomething, type: :model do 
     describe "somthing" do
       it {
         should define_enum_for(:button_alignment)
-          .with([:centre, :left, :right])
+          .with_values([:centre, :left, :right])
       }
     end
   end
Enter fullscreen mode Exit fullscreen mode

I feel like I've added a few months to my life as this no longer causes stress. I just live here

Top comments (0)