{"action":"opened","issue":{"url":"https://api.github.com/repos/spotbugs/discuss/issues/1","repository_url":"https://api.github.com/repos/spotbugs/discuss","labels_url":"https://api.github.com/repos/spotbugs/discuss/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/spotbugs/discuss/issues/1/comments","events_url":"https://api.github.com/repos/spotbugs/discuss/issues/1/events","html_url":"https://github.com/spotbugs/discuss/issues/1","id":243381696,"number":1,"title":"How to pass user-configurable options to a detector?","user":{"login":"sewe","id":491981,"avatar_url":"https://avatars6.githubusercontent.com/u/491981?v=4","gravatar_id":"","url":"https://api.github.com/users/sewe","html_url":"https://github.com/sewe","followers_url":"https://api.github.com/users/sewe/followers","following_url":"https://api.github.com/users/sewe/following{/other_user}","gists_url":"https://api.github.com/users/sewe/gists{/gist_id}","starred_url":"https://api.github.com/users/sewe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sewe/subscriptions","organizations_url":"https://api.github.com/users/sewe/orgs","repos_url":"https://api.github.com/users/sewe/repos","events_url":"https://api.github.com/users/sewe/events{/privacy}","received_events_url":"https://api.github.com/users/sewe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-17T12:37:54Z","updated_at":"2017-07-17T12:37:54Z","closed_at":null,"body":"This issue is meant to discuss **best practices** for how to pass additional, user-configurable options to a detector. As far as I can see, there are three alternatives to do so:\r\n\r\n1. Pass the option in as a system property (`-jvmArgs -Dkey=value` command line option)\r\n2. Pass the option in as a key/value pair in the user preferences file (`-userPrefs` command line option)\r\n3. Pass a (pre-defined) key/value pair in through activation/deactivation of a special plug-in with `<GlobalOption>` (`-choosePlugins` command line option)\r\n\r\nThe preferred alternative should offer a straight-forward way to access the value in the detector:\r\n\r\n1. The canonical way to access them seems to be `SystemProperties.getProperty(String)`\r\n2. *I haven’t found a way to get at a `UserPreferences` object from within a `Detector`*\r\n3. *I haven’t found a way (spotbugs/spotbugs@dbdd6c50acf232d9ec80ad3fbcefb5eda2f28aed removed `DetectorCollectionFactory.getGlobalOption`)*\r\n\r\nMoreover, the preferred alternative should not only work when SpotBugs is invoked from the command line, but should also be settable from within Eclipse, e.g., through a preference page.\r\n\r\n1. Seems trivial, but is surprisingly tricky, as the system property needs to be set on every restart. (Just because the SpotBugs Eclipse plug-in uses the `findbugsPlugins` extension point to load a SpotBugs plugin doesn’t mean that the surrounding Eclipse plug-in wrapper’s Activator is run; so you can’t set the system property anew on demand when the wrapper is activated.)\r\n2. Can be achieved through `FindbugsPlugin.getUserPreferences(...)` and `saveUserPreferences(...)` called from the preference page or even (per-project) from the project’s *Properties* page\r\n3. Activation/Deactivation can be done in the *Java > SpotBugs > Plugins and misc. Settings* preferences. (This is limited to boolean options, of course.)\r\n\r\nAm I missing any other alternatives? How can alternatives 2 and 3 above access the configured value in the detector? And which alternative should in your opinion be considered a best practice?"}}
{"actor":{"display_login":"sewe"}}