{"action":"created","issue":{"url":"https://api.github.com/repos/rrrene/credo/issues/526","repository_url":"https://api.github.com/repos/rrrene/credo","labels_url":"https://api.github.com/repos/rrrene/credo/issues/526/labels{/name}","comments_url":"https://api.github.com/repos/rrrene/credo/issues/526/comments","events_url":"https://api.github.com/repos/rrrene/credo/issues/526/events","html_url":"https://github.com/rrrene/credo/issues/526","id":313934013,"number":526,"title":"Bug: Pefer lazy Logger calls should take in consideration compile_time_purge_level: :debug option for :logger","user":{"login":"cblage","id":939776,"avatar_url":"https://avatars1.githubusercontent.com/u/939776?v=4","gravatar_id":"","url":"https://api.github.com/users/cblage","html_url":"https://github.com/cblage","followers_url":"https://api.github.com/users/cblage/followers","following_url":"https://api.github.com/users/cblage/following{/other_user}","gists_url":"https://api.github.com/users/cblage/gists{/gist_id}","starred_url":"https://api.github.com/users/cblage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cblage/subscriptions","organizations_url":"https://api.github.com/users/cblage/orgs","repos_url":"https://api.github.com/users/cblage/repos","events_url":"https://api.github.com/users/cblage/events{/privacy}","received_events_url":"https://api.github.com/users/cblage/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":21,"created_at":"2018-04-13T00:50:46Z","updated_at":"2018-04-13T14:48:17Z","closed_at":null,"author_association":"NONE","body":"## Configuration\r\n\r\n```elixir\r\n# This file is responsible for configuring your application\r\n# and its dependencies with the aid of the Mix.Config module.\r\nuse Mix.Config\r\n\r\nconfig :logger,\r\n       level: :info,\r\n       compile_time_purge_level: :debug\r\n```\r\n\r\n## Issue\r\n\r\nWhen using the `compile_time_purge_level: :debug` option, all `Logger` calls matching it are REMOVED from the source at compile time. \r\n\r\nCredo should take this option in consideration before issuing warnings.\r\n\r\n### Environment\r\n\r\n* Credo version (`mix credo -v`):  0.9.1\r\n* Erlang/Elixir version (`elixir -v`):\r\nErlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]\r\n\r\nElixir 1.6.3 (compiled with OTP 19)\r\n* Operating system: Windows 10 Pro 64 Bit\r\n\r\n### What were you trying to do?\r\n\r\nRunning `mix credo --strict`\r\n\r\n\r\n### Expected outcome\r\n\r\nNo warnings\r\n\r\n### Actual outcome\r\n\r\n```\r\n➜  json git:(develop) ✗ mix credo --strict\r\n➜  json git:(develop) ✗ mix credo --strict\r\nChecking 17 source files ...\r\n\r\n  Warnings - please take a look\r\n┃\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser/array.ex:80 #(JSON.Parser.Array.parse_array_contents)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser/array.ex:77 #(JSON.Parser.Array.parse_array_contents)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser/array.ex:71 #(JSON.Parser.Array.parse_array_contents)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser/array.ex:68 #(JSON.Parser.Array.parse_array_contents)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser/array.ex:61 #(JSON.Parser.Array.parse_array_contents)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser/array.ex:55 #(JSON.Parser.Array.parse_array_contents)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser/array.ex:49 #(JSON.Parser.Array.parse_array_contents)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser/array.ex:43 #(JSON.Parser.Array.parse)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser/array.ex:39 #(JSON.Parser.Array.parse)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser/array.ex:34 #(JSON.Parser.Array.parse)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser.ex:108 #(JSON.Parser.parse)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser.ex:104 #(JSON.Parser.parse)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser.ex:100 #(JSON.Parser.parse)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser.ex:96 #(JSON.Parser.parse)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser.ex:92 #(JSON.Parser.parse)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser.ex:88 #(JSON.Parser.parse)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser.ex:84 #(JSON.Parser.parse)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser.ex:80 #(JSON.Parser.parse)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser.ex:76 #(JSON.Parser.parse)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/parser.ex:72 #(JSON.Parser.parse)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/decoder.ex:97 #(JSON.Decoder.DefaultImplementations.decode)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/decoder.ex:94 #(JSON.Decoder.DefaultImplementations.decode)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/decoder.ex:91 #(JSON.Decoder.DefaultImplementations.decode)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/decoder.ex:55 #(JSON.Decoder.DefaultImplementations.decode)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/decoder.ex:52 #(JSON.Decoder.DefaultImplementations.decode)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/decoder.ex:51 #(JSON.Decoder.DefaultImplementations.decode)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/decoder.ex:48 #(JSON.Decoder.DefaultImplementations.decode)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/decoder.ex:45 #(JSON.Decoder.DefaultImplementations.decode)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json/decoder.ex:39 #(JSON.Decoder.DefaultImplementations.decode)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json.ex:93 #(JSON.decode!)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json.ex:90 #(JSON.decode!)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json.ex:87 #(JSON.decode!)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json.ex:84 #(JSON.decode!)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json.ex:67 #(JSON.decode)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json.ex:64 #(JSON.decode)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json.ex:61 #(JSON.decode)\r\n┃ [W] ↗ Prefer lazy Logger calls.\r\n┃       lib/json.ex:58 #(JSON.decode)\r\n\r\nPlease report incorrect results: https://github.com/rrrene/credo/issues\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/rrrene/credo/issues/comments/381159455","html_url":"https://github.com/rrrene/credo/issues/526#issuecomment-381159455","issue_url":"https://api.github.com/repos/rrrene/credo/issues/526","id":381159455,"user":{"login":"cblage","id":939776,"avatar_url":"https://avatars1.githubusercontent.com/u/939776?v=4","gravatar_id":"","url":"https://api.github.com/users/cblage","html_url":"https://github.com/cblage","followers_url":"https://api.github.com/users/cblage/followers","following_url":"https://api.github.com/users/cblage/following{/other_user}","gists_url":"https://api.github.com/users/cblage/gists{/gist_id}","starred_url":"https://api.github.com/users/cblage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cblage/subscriptions","organizations_url":"https://api.github.com/users/cblage/orgs","repos_url":"https://api.github.com/users/cblage/repos","events_url":"https://api.github.com/users/cblage/events{/privacy}","received_events_url":"https://api.github.com/users/cblage/received_events","type":"User","site_admin":false},"created_at":"2018-04-13T14:48:17Z","updated_at":"2018-04-13T14:48:17Z","author_association":"NONE","body":"\"Found the discussion, can read up here as to their reasonings: elixir-lang/elixir#7046\r\n\r\n:-)\r\n\r\nEssentially though, your logger calls have potential side effects because they are calling a function in a remote module, thus when the code is purged then it can be surprising to many programmers that those side effects no longer do anything, where making it an explicit function makes it more obvious that it is self contained and may or may not be called. In addition the expression is run regardless when not purged even when not logging, thus even if not side-effecting then it slow has the slowdown associated with it, thus forcing it to be a function removes that accidental cost. Definitely feel free to weigh in at the above issue though! :-)\"\r\n\r\n\r\nIf your log calls have side effects, please turn in your badge at the exit and go find a new profession."}}
{"actor":{"display_login":"cblage"}}