{"action":"created","comment":{"url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/pulls/comments/181823442","pull_request_review_id":112514904,"id":181823442,"diff_hunk":"@@ -51,8 +51,11 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)\n                                     {\r\n                                         if (String.Equals(namedArgument.ArgumentName, \"mandatory\", StringComparison.OrdinalIgnoreCase))\r\n                                         {\r\n-                                            // 2 cases: [Parameter(Mandatory)] and [Parameter(Mandatory=$true)]\r\n-                                            if (namedArgument.ExpressionOmitted || (!namedArgument.ExpressionOmitted && String.Equals(namedArgument.Argument.Extent.Text, \"$true\", StringComparison.OrdinalIgnoreCase)))\r\n+                                            // 3 cases: [Parameter(Mandatory)], [Parameter(Mandatory=$true)] and [Parameter(Mandatory=value)] where value is not equal to 0.\r\n+                                            int mandatoryValue = 0;\r\n+                                            if (namedArgument.ExpressionOmitted\r\n+                                                || (String.Equals(namedArgument.Argument.Extent.Text, \"$true\", StringComparison.OrdinalIgnoreCase))\r\n+                                                || (int.TryParse(namedArgument.Argument.Extent.Text, out mandatoryValue) && mandatoryValue != 0))\r","path":"Rules/AvoidDefaultValueForMandatoryParameter.cs","position":10,"original_position":10,"commit_id":"a49cdafb3b5b635fe8ecb74d7818000d73961167","original_commit_id":"a49cdafb3b5b635fe8ecb74d7818000d73961167","user":{"login":"kalgiz","id":7048436,"avatar_url":"https://avatars0.githubusercontent.com/u/7048436?v=4","gravatar_id":"","url":"https://api.github.com/users/kalgiz","html_url":"https://github.com/kalgiz","followers_url":"https://api.github.com/users/kalgiz/followers","following_url":"https://api.github.com/users/kalgiz/following{/other_user}","gists_url":"https://api.github.com/users/kalgiz/gists{/gist_id}","starred_url":"https://api.github.com/users/kalgiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalgiz/subscriptions","organizations_url":"https://api.github.com/users/kalgiz/orgs","repos_url":"https://api.github.com/users/kalgiz/repos","events_url":"https://api.github.com/users/kalgiz/events{/privacy}","received_events_url":"https://api.github.com/users/kalgiz/received_events","type":"User","site_admin":false},"body":"Currently the powershell interpreter accepts every numeric value of Mandatory parameter. So all the following: Parameter(Mandatory=1), Parameter(Mandatory=-1), Parameter(Mandatory=100) are acceptable and mean that PowerShell treats the parameter as mandatory. Only in case Parameter(Mandatory=0), the parameter is not mandatory.\r\n\r\nHence, I adjusted the rule to the way PowerShell works, but definieily specifying parameter as e.g. Parameter(Mandatory=-100) is not a good coding practice... Maybe we should add some special rule for that?","created_at":"2018-04-16T17:27:54Z","updated_at":"2018-04-16T17:27:54Z","html_url":"https://github.com/PowerShell/PSScriptAnalyzer/pull/969#discussion_r181823442","pull_request_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/pulls/969","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/pulls/comments/181823442"},"html":{"href":"https://github.com/PowerShell/PSScriptAnalyzer/pull/969#discussion_r181823442"},"pull_request":{"href":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/pulls/969"}},"in_reply_to_id":181507677},"pull_request":{"url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/pulls/969","id":181344667,"html_url":"https://github.com/PowerShell/PSScriptAnalyzer/pull/969","diff_url":"https://github.com/PowerShell/PSScriptAnalyzer/pull/969.diff","patch_url":"https://github.com/PowerShell/PSScriptAnalyzer/pull/969.patch","issue_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/issues/969","number":969,"state":"open","locked":false,"title":"AvoidDefaultValueForMandatoryParameter triggers when the field has specification: Mandatory=value and value!=0","user":{"login":"kalgiz","id":7048436,"avatar_url":"https://avatars0.githubusercontent.com/u/7048436?v=4","gravatar_id":"","url":"https://api.github.com/users/kalgiz","html_url":"https://github.com/kalgiz","followers_url":"https://api.github.com/users/kalgiz/followers","following_url":"https://api.github.com/users/kalgiz/following{/other_user}","gists_url":"https://api.github.com/users/kalgiz/gists{/gist_id}","starred_url":"https://api.github.com/users/kalgiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalgiz/subscriptions","organizations_url":"https://api.github.com/users/kalgiz/orgs","repos_url":"https://api.github.com/users/kalgiz/repos","events_url":"https://api.github.com/users/kalgiz/events{/privacy}","received_events_url":"https://api.github.com/users/kalgiz/received_events","type":"User","site_admin":false},"body":"## PR Summary\r\n\r\nAvoidDefaultValueForMandatoryParameter triggers when the field has specification: Mandatory=value and value is not equal to 0.\r\n\r\nFixes: #877 \r\n\r\n## PR Checklist\r\n\r\nNote: Tick the boxes below that apply to this pull request by putting an `x` between the square brackets. Please mark anything not applicable to this PR `NA`.\r\n\r\n- [x] PR has a meaningful title\r\n    - [x] Use the present tense and imperative mood when describing your changes\r\n- [x] Summarized changes\r\n- [ ] User facing documentation needed\r\n- [x] Change is not breaking\r\n- [x] Make sure you've added a new test if existing tests do not effectively test the code changed\r\n- [x] This PR is ready to merge and is not work in progress\r\n    - If the PR is work in progress, please add the prefix `WIP:` to the beginning of the title and remove the prefix when the PR is ready\r\n","created_at":"2018-04-12T22:43:08Z","updated_at":"2018-04-16T17:27:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f8651bcc610fbd25c02f7c99f997c07bde913bd9","assignee":null,"assignees":[],"requested_reviewers":[{"login":"JamesWTruher","id":10214008,"avatar_url":"https://avatars2.githubusercontent.com/u/10214008?v=4","gravatar_id":"","url":"https://api.github.com/users/JamesWTruher","html_url":"https://github.com/JamesWTruher","followers_url":"https://api.github.com/users/JamesWTruher/followers","following_url":"https://api.github.com/users/JamesWTruher/following{/other_user}","gists_url":"https://api.github.com/users/JamesWTruher/gists{/gist_id}","starred_url":"https://api.github.com/users/JamesWTruher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JamesWTruher/subscriptions","organizations_url":"https://api.github.com/users/JamesWTruher/orgs","repos_url":"https://api.github.com/users/JamesWTruher/repos","events_url":"https://api.github.com/users/JamesWTruher/events{/privacy}","received_events_url":"https://api.github.com/users/JamesWTruher/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":207947529,"url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/labels/in%20progress","name":"in progress","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/pulls/969/commits","review_comments_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/pulls/969/comments","review_comment_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/issues/969/comments","statuses_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/statuses/a49cdafb3b5b635fe8ecb74d7818000d73961167","head":{"label":"kalgiz:avoid-default-value-for-mandatory-fix","ref":"avoid-default-value-for-mandatory-fix","sha":"a49cdafb3b5b635fe8ecb74d7818000d73961167","user":{"login":"kalgiz","id":7048436,"avatar_url":"https://avatars0.githubusercontent.com/u/7048436?v=4","gravatar_id":"","url":"https://api.github.com/users/kalgiz","html_url":"https://github.com/kalgiz","followers_url":"https://api.github.com/users/kalgiz/followers","following_url":"https://api.github.com/users/kalgiz/following{/other_user}","gists_url":"https://api.github.com/users/kalgiz/gists{/gist_id}","starred_url":"https://api.github.com/users/kalgiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalgiz/subscriptions","organizations_url":"https://api.github.com/users/kalgiz/orgs","repos_url":"https://api.github.com/users/kalgiz/repos","events_url":"https://api.github.com/users/kalgiz/events{/privacy}","received_events_url":"https://api.github.com/users/kalgiz/received_events","type":"User","site_admin":false},"repo":{"id":124284887,"name":"PSScriptAnalyzer","full_name":"kalgiz/PSScriptAnalyzer","owner":{"login":"kalgiz","id":7048436,"avatar_url":"https://avatars0.githubusercontent.com/u/7048436?v=4","gravatar_id":"","url":"https://api.github.com/users/kalgiz","html_url":"https://github.com/kalgiz","followers_url":"https://api.github.com/users/kalgiz/followers","following_url":"https://api.github.com/users/kalgiz/following{/other_user}","gists_url":"https://api.github.com/users/kalgiz/gists{/gist_id}","starred_url":"https://api.github.com/users/kalgiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalgiz/subscriptions","organizations_url":"https://api.github.com/users/kalgiz/orgs","repos_url":"https://api.github.com/users/kalgiz/repos","events_url":"https://api.github.com/users/kalgiz/events{/privacy}","received_events_url":"https://api.github.com/users/kalgiz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kalgiz/PSScriptAnalyzer","description":"Download ScriptAnalyzer from PowerShellGallery","fork":true,"url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer","forks_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/forks","keys_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/teams","hooks_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/hooks","issue_events_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/issues/events{/number}","events_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/events","assignees_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/assignees{/user}","branches_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/branches{/branch}","tags_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/tags","blobs_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/git/refs{/sha}","trees_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/statuses/{sha}","languages_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/languages","stargazers_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/stargazers","contributors_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/contributors","subscribers_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/subscribers","subscription_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/subscription","commits_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/commits{/sha}","git_commits_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/git/commits{/sha}","comments_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/comments{/number}","issue_comment_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/issues/comments{/number}","contents_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/contents/{+path}","compare_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/merges","archive_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/downloads","issues_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/issues{/number}","pulls_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/pulls{/number}","milestones_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/milestones{/number}","notifications_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/labels{/name}","releases_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/releases{/id}","deployments_url":"https://api.github.com/repos/kalgiz/PSScriptAnalyzer/deployments","created_at":"2018-03-07T19:35:08Z","updated_at":"2018-04-12T21:16:49Z","pushed_at":"2018-04-12T23:17:30Z","git_url":"git://github.com/kalgiz/PSScriptAnalyzer.git","ssh_url":"git@github.com:kalgiz/PSScriptAnalyzer.git","clone_url":"https://github.com/kalgiz/PSScriptAnalyzer.git","svn_url":"https://github.com/kalgiz/PSScriptAnalyzer","homepage":"https://www.powershellgallery.com/packages/PSScriptAnalyzer/","size":3403,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"development"}},"base":{"label":"PowerShell:development","ref":"development","sha":"6966d511fe1a6fdba9d189712238a38fff05128b","user":{"login":"PowerShell","id":11524380,"avatar_url":"https://avatars3.githubusercontent.com/u/11524380?v=4","gravatar_id":"","url":"https://api.github.com/users/PowerShell","html_url":"https://github.com/PowerShell","followers_url":"https://api.github.com/users/PowerShell/followers","following_url":"https://api.github.com/users/PowerShell/following{/other_user}","gists_url":"https://api.github.com/users/PowerShell/gists{/gist_id}","starred_url":"https://api.github.com/users/PowerShell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PowerShell/subscriptions","organizations_url":"https://api.github.com/users/PowerShell/orgs","repos_url":"https://api.github.com/users/PowerShell/repos","events_url":"https://api.github.com/users/PowerShell/events{/privacy}","received_events_url":"https://api.github.com/users/PowerShell/received_events","type":"Organization","site_admin":false},"repo":{"id":33149177,"name":"PSScriptAnalyzer","full_name":"PowerShell/PSScriptAnalyzer","owner":{"login":"PowerShell","id":11524380,"avatar_url":"https://avatars3.githubusercontent.com/u/11524380?v=4","gravatar_id":"","url":"https://api.github.com/users/PowerShell","html_url":"https://github.com/PowerShell","followers_url":"https://api.github.com/users/PowerShell/followers","following_url":"https://api.github.com/users/PowerShell/following{/other_user}","gists_url":"https://api.github.com/users/PowerShell/gists{/gist_id}","starred_url":"https://api.github.com/users/PowerShell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PowerShell/subscriptions","organizations_url":"https://api.github.com/users/PowerShell/orgs","repos_url":"https://api.github.com/users/PowerShell/repos","events_url":"https://api.github.com/users/PowerShell/events{/privacy}","received_events_url":"https://api.github.com/users/PowerShell/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PowerShell/PSScriptAnalyzer","description":"Download ScriptAnalyzer from PowerShellGallery","fork":false,"url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer","forks_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/forks","keys_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/teams","hooks_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/hooks","issue_events_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/issues/events{/number}","events_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/events","assignees_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/assignees{/user}","branches_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/branches{/branch}","tags_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/tags","blobs_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/git/refs{/sha}","trees_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/statuses/{sha}","languages_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/languages","stargazers_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/stargazers","contributors_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/contributors","subscribers_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/subscribers","subscription_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/subscription","commits_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/commits{/sha}","git_commits_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/git/commits{/sha}","comments_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/comments{/number}","issue_comment_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/issues/comments{/number}","contents_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/contents/{+path}","compare_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/merges","archive_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/downloads","issues_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/issues{/number}","pulls_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/pulls{/number}","milestones_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/milestones{/number}","notifications_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/labels{/name}","releases_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/releases{/id}","deployments_url":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/deployments","created_at":"2015-03-30T21:26:25Z","updated_at":"2018-04-16T12:57:42Z","pushed_at":"2018-04-14T10:59:59Z","git_url":"git://github.com/PowerShell/PSScriptAnalyzer.git","ssh_url":"git@github.com:PowerShell/PSScriptAnalyzer.git","clone_url":"https://github.com/PowerShell/PSScriptAnalyzer.git","svn_url":"https://github.com/PowerShell/PSScriptAnalyzer","homepage":"https://www.powershellgallery.com/packages/PSScriptAnalyzer/","size":3404,"stargazers_count":514,"watchers_count":514,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":127,"mirror_url":null,"archived":false,"open_issues_count":167,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":127,"open_issues":167,"watchers":514,"default_branch":"development"}},"_links":{"self":{"href":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/pulls/969"},"html":{"href":"https://github.com/PowerShell/PSScriptAnalyzer/pull/969"},"issue":{"href":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/issues/969"},"comments":{"href":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/issues/969/comments"},"review_comments":{"href":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/pulls/969/comments"},"review_comment":{"href":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/pulls/969/commits"},"statuses":{"href":"https://api.github.com/repos/PowerShell/PSScriptAnalyzer/statuses/a49cdafb3b5b635fe8ecb74d7818000d73961167"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"kalgiz"}}