Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-11156

Useless code in shell save() function

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.5.4
    • Affects Version/s: 2.4.6
    • Component/s: Shell
    • Environment:
      Linux
    • Fully Compatible
    • Linux
    • Hide

      launch shell
      type db.foo.save
      look at source

      Show
      launch shell type db.foo.save look at source

      save() starts by this:

      if ( obj == null || typeof( obj ) == "undefined" )
      throw "can't save a null";

      This is apparently to catch both null and undefined.

      However, since the first check only uses == instead of ===, it matches undefined, and the second part of the check is never used. This could be improved in one of two ways:

      • drop the second part of the check since it is unused anyway:
        if ( obj == null)
        throw "can't save a null";
      • use an identical check for null
        if ( obj === null || typeof( obj ) == "undefined" )
        throw "can't save a null";

            Assignee:
            Unassigned Unassigned
            Reporter:
            fgm@osinet.fr Frédéric G. MARAND
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: