{"id":793,"date":"2020-01-11T22:13:21","date_gmt":"2020-01-11T22:13:21","guid":{"rendered":"https:\/\/sdf-docs.mansystems.com\/docs\/acr-rules\/reliability\/variables-should-not-be-indirectly-compared-to-empty\/"},"modified":"2020-03-20T08:44:58","modified_gmt":"2020-03-20T08:44:58","slug":"indirectemptycompare","status":"publish","type":"docs","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/reliability\/indirectemptycompare","title":{"rendered":"Variables should not be indirectly compared to empty"},"content":{"rendered":"\n<p>This is likely a bug. If an object, variable or attribute is guaranteed to be empty then it does not make a lot of sense to compare against it. Use an explicit empty instead.<\/p>\n\n\n\n<p><strong>Noncompliant example:<\/strong><\/p>\n\n\n\n<p><code>if $Object = empty and $Object\/Attribute = $Var<br>then 'A'<br>else 'B'<\/code><\/p>\n\n\n\n<p><strong>Compliant example:<\/strong><\/p>\n\n\n\n<p><code>if $Object = empty or $Object\/Attribute = $Var<br>then 'A'<br>else 'B'<\/code><\/p>\n","protected":false},"featured_media":0,"parent":97,"menu_order":26,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-793","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/793"}],"collection":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=793"}],"version-history":[{"count":1,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/793\/revisions"}],"predecessor-version":[{"id":794,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/793\/revisions\/794"}],"up":[{"embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/97"}],"next":[{"title":"Week year should not be used in date formatting or parsing","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/reliability\/weekyear","href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/776"}],"prev":[{"title":"System.User and System.Session objects should not be created directly","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/reliability\/createsystementity","href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/277"}],"wp:attachment":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=793"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}