{"id":1147,"date":"2020-02-03T10:21:59","date_gmt":"2020-02-03T10:21:59","guid":{"rendered":"https:\/\/sdf-docs.mansystems.com\/docs\/acr-rules\/performance\/long-running-actions-should-be-used-outside-of-a-loop\/"},"modified":"2020-07-08T14:35:30","modified_gmt":"2020-07-08T14:35:30","slug":"loopheavyaction","status":"publish","type":"docs","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/performance\/loopheavyaction","title":{"rendered":"Only short actions should be used in a loop"},"content":{"rendered":"\n<p>Introduced in version 1.4 (3 February 2020)<\/p>\n\n\n<p>A loop can potentially be executed hundreds or thousands of times. Therefore it is preferable to avoid doing long-running actions in a loop.<br><!--StartFragment--><\/p>\n\n\n<p>Database retrieves can sometimes be refactored to 1 retrieve before the loop and a find-action on the list inside the loop. <\/p>\n\n\n\n<p>Other long-running actions such as rest calls have no standard recipe to refactor. Consider this rule as a warning and whitelist them, or change the settings and allow certain actions <\/p>\n\n\n<p><!--EndFragment--><\/p>\n\n\n<p>Rule configuration can define heavy actions:<\/p>\n\n\n\n<p> [ {&#8220;Action&#8221;:&#8221;AppServiceCallAction&#8221;}, {&#8220;Action&#8221;:&#8221;DownloadFileAction&#8221;}, {&#8220;Action&#8221;:&#8221;JavaActionCallAction&#8221;}, {&#8220;Action&#8221;:&#8221;RetrieveAction&#8221;, &#8220;Database&#8221;: true}, {&#8220;Action&#8221;:&#8221;RestCallAction&#8221;}, {&#8220;Action&#8221;:&#8221;GenerateDocumentAction&#8221;}, {&#8220;Action&#8221;:&#8221;ExportXmlAction&#8221;} {&#8220;Action&#8221;:,&#8221;ImportXmlAction&#8221;} ] <\/p>\n\n\n\n<p>\n\nLeaving the configuration empty takes this default.\n\n<\/p>\n","protected":false},"featured_media":0,"parent":95,"menu_order":22,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-1147","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/1147"}],"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=1147"}],"version-history":[{"count":5,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/1147\/revisions"}],"predecessor-version":[{"id":1159,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/1147\/revisions\/1159"}],"up":[{"embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/95"}],"next":[{"title":"Positive conditions should be preferred when retrieving data","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/performance\/negativepositivexpath","href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/235"}],"prev":[{"title":"Not\/or expressions in XPath should be avoided when the path goes over an association","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/performance\/notorxpath","href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/1221"}],"wp:attachment":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1147"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=1147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}