{"action":"created","issue":{"url":"https://api.github.com/repos/joakimkarlsson/bandit/issues/72","repository_url":"https://api.github.com/repos/joakimkarlsson/bandit","labels_url":"https://api.github.com/repos/joakimkarlsson/bandit/issues/72/labels{/name}","comments_url":"https://api.github.com/repos/joakimkarlsson/bandit/issues/72/comments","events_url":"https://api.github.com/repos/joakimkarlsson/bandit/issues/72/events","html_url":"https://github.com/joakimkarlsson/bandit/pull/72","id":148466408,"number":72,"title":"Separating registration of from access to registered values","user":{"login":"Marc--Olivier","id":8179792,"avatar_url":"https://avatars.githubusercontent.com/u/8179792?v=3","gravatar_id":"","url":"https://api.github.com/users/Marc--Olivier","html_url":"https://github.com/Marc--Olivier","followers_url":"https://api.github.com/users/Marc--Olivier/followers","following_url":"https://api.github.com/users/Marc--Olivier/following{/other_user}","gists_url":"https://api.github.com/users/Marc--Olivier/gists{/gist_id}","starred_url":"https://api.github.com/users/Marc--Olivier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Marc--Olivier/subscriptions","organizations_url":"https://api.github.com/users/Marc--Olivier/orgs","repos_url":"https://api.github.com/users/Marc--Olivier/repos","events_url":"https://api.github.com/users/Marc--Olivier/events{/privacy}","received_events_url":"https://api.github.com/users/Marc--Olivier/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-04-14T19:59:50Z","updated_at":"2016-04-17T13:12:53Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/joakimkarlsson/bandit/pulls/72","html_url":"https://github.com/joakimkarlsson/bandit/pull/72","diff_url":"https://github.com/joakimkarlsson/bandit/pull/72.diff","patch_url":"https://github.com/joakimkarlsson/bandit/pull/72.patch"},"body":"Hi guys,\r\n\r\nI am currently looking for different unit test tools and bandit seems a very interesting choice!\r\nHowever, when running clang-tidy on a minimal project, I get some warnings and I do not want any warning (as I set an option so that they automatically trigger errors)...\r\n\r\nThese warnings are related to the registration and access to registered values contained in a single function for run_policy and listener (it is a bit tricky to initialise static variables in header files...). The two commits of this pull request fix these warnings and, in my opinion, improve a bit the design as the registration and the access to the variables are now in two different functions and enable to test if they have been registered before being retrieved (but there is more code because of the initialisation of the static variables...).\r\n\r\nPlease let me know what your thoughts are! And do not hesitate to ask me to do some changes so that the code I wrote is more consistent with the rest of the code (I only guessed the style from a few snippets I could see).\r\n\r\nKind regards,\r\n\r\nMarc-Olivier\r\n\r\nPS: I have run travis on my branch and it seems to pass.\r\nPS: the small file generating the errors was based on the second example of http://banditcpp.org/writingtests.html:\r\n```c++\r\n#include <bandit/bandit.h>\r\n\r\n// Tell bandit there are tests here.\r\ngo_bandit([](){\r\n  bandit::describe(\"our first test\", [](){\r\n    bandit::it(\"should fail\", [&](){\r\n      AssertThat(6, Equals(6));\r\n    });\r\n  });\r\n});\r\n\r\nint main(int argc, char* argv[])\r\n{\r\n  // Run the tests.\r\n  return bandit::run(argc, argv);\r\n} \r\n```\r\n\r\nPS: And if you want more info to install/run clang-tidy, do not hesitate to contact me."},"comment":{"url":"https://api.github.com/repos/joakimkarlsson/bandit/issues/comments/211014808","html_url":"https://github.com/joakimkarlsson/bandit/pull/72#issuecomment-211014808","issue_url":"https://api.github.com/repos/joakimkarlsson/bandit/issues/72","id":211014808,"user":{"login":"lefticus","id":234279,"avatar_url":"https://avatars.githubusercontent.com/u/234279?v=3","gravatar_id":"","url":"https://api.github.com/users/lefticus","html_url":"https://github.com/lefticus","followers_url":"https://api.github.com/users/lefticus/followers","following_url":"https://api.github.com/users/lefticus/following{/other_user}","gists_url":"https://api.github.com/users/lefticus/gists{/gist_id}","starred_url":"https://api.github.com/users/lefticus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lefticus/subscriptions","organizations_url":"https://api.github.com/users/lefticus/orgs","repos_url":"https://api.github.com/users/lefticus/repos","events_url":"https://api.github.com/users/lefticus/events{/privacy}","received_events_url":"https://api.github.com/users/lefticus/received_events","type":"User","site_admin":false},"created_at":"2016-04-17T13:12:53Z","updated_at":"2016-04-17T13:12:53Z","body":"Well, since you brought me into this conversation... I'm assuming you don't normally build on Windows hence the conversion warnings. If you turn clang warnings up as high as you can handle (my settings currently are: `-Weverything -Wno-c++98-compat-pedantic  -Wno-c++98-compat -Wno-documentation -Wno-switch-enum -Wno-weak-vtables -Wno-missing-prototypes -Wno-padded -Wno-missing-noreturn -Wno-exit-time-destructors -Wno-documentation-unknown-command`) you should get most of those truncation warnings to show up in clang too. MSVC can be very pedantic and annoying about these things - but it's correct. You might be losing precision / sign when you don't expect to and you might be incurring an extra runtime cost for it."}}