Giter VIP home page Giter VIP logo

Comments (4)

rzane avatar rzane commented on June 28, 2024 2

Hmm... sort of, but this feels pretty like it would cause unexpected problems that would be really hard to figure out what went wrong. Plus, then we'd have to support !field.nil? to produce an IS NOT NULL query.

I would rather add is_null(field) and is_not_null(field)

from baby_squeel.

chewi avatar chewi commented on June 28, 2024

One problem with field == nil is that RuboCop keeps trying to replace it with .nil? !

from baby_squeel.

pelletencate avatar pelletencate commented on June 28, 2024

Yeah, the initial reason why I proposed this change was Rubocop complaining. I feel kinda stupid not thinking about !field.nil?, that's a more legit concern than whatever I have.

tbh, is_null or is_not_null, while it would please rubocop, would in my opinion be a step in the wrong direction. A better thing would be to have @bbatsov et al join in, to think about the possibility to provide a custom rubocop plug with your gem, or – more generally – if there's anything that would help accommodate cases (a/o DSL) where the == operator gets overloaded.

Besides, Rubocop also complains about == 0. And making an is_zero?(field) and is_not_zero?(field), would be even more unnecessary.

from baby_squeel.

bbatsov avatar bbatsov commented on June 28, 2024

One problem with field == nil is that RuboCop keeps trying to replace it with .nil? !

That's configurable. :) Obviously a static analyzer can't really figure out that something might be a special DSL. I think in such situations you can just exclude the DSL files from the checks and be done with it.

from baby_squeel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.