Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PSSA for Turkish culture and tests when culture is not en-US #1099

Merged
merged 20 commits into from
Mar 8, 2019

Conversation

bergmeister
Copy link
Collaborator

@bergmeister bergmeister commented Nov 8, 2018

PR Summary

PR Checklist

@bergmeister bergmeister changed the title WIP More fixes for turkish culture Fixes PSSA for Turkish culture and tests when culture is not en-US Nov 12, 2018
@bergmeister bergmeister changed the title Fixes PSSA for Turkish culture and tests when culture is not en-US Fix PSSA for Turkish culture and tests when culture is not en-US Nov 12, 2018
@bergmeister bergmeister added this to the 1.18 milestone Nov 12, 2018
Copy link
Contributor

@JamesWTruher JamesWTruher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in PowerShell, we've been instructed to use StringComparer.OrdinalIgnoreCase. I'm thinking that we should do that here as well unless there's a really good reason not to.
http://msdn.microsoft.com/en-us/library/system.stringcomparer.ordinalignorecase.aspx
http://msdn.microsoft.com/en-us/library/system.stringcomparer.invariantcultureignorecase.aspx

@bergmeister
Copy link
Collaborator Author

Ok, I've made it use OrdinalIgnoreCase instead everywhere

@bergmeister bergmeister added the (Re-)Review Needed Feedback has been addressed during PR stage or is required in the first place. label Jan 29, 2019
fix also ToLower call in new compatibility module
# Conflicts:
#	Engine/ScriptAnalyzer.cs
#	Engine/Settings.cs
#	tools/appveyor.psm1
Copy link
Contributor

@rjmholt rjmholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Engine/Generic/RuleSuppression.cs Outdated Show resolved Hide resolved
goto default;
RuleName = (name.Argument as StringConstantExpressionAst).Value;
}
else if (argumentName.Equals("rulesuppressionid", StringComparison.OrdinalIgnoreCase))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of else ifs in this method and I had to read all of them to check that some kind of state isn't being manipulated by all of them. Would it be easier to use return?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, one would have to move it into a function and other variables would need to be passed to it and there is no else, meaning the caller of it would need an if (returnValue != null) check. I don't think the juice is worth the squeeze here, especially for code that is not likely to be changed and this change is not adding any functionality that would justify such a refactor (any refactor also comes with the risk of a regression, I am not saying we should not change in general, but there seems to be little benefit to me here). Even if previous code is not the best, as long as it does not appear to be dangerously bad, I'd not change it too much in this instance

Engine/Generic/RuleSuppression.cs Outdated Show resolved Hide resolved
break;
default:
return false;
severityList.AddRange(values);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It strikes me that it would be simpler to just return true here and in the next clause and just return false at the end by default

Copy link
Collaborator Author

@bergmeister bergmeister Mar 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I agree, I''ve addressed that in this commit

break;

default:
if (settingKey.Equals("severity", StringComparison.OrdinalIgnoreCase) ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to suggest changes here, but I keep thinking about the rest of the file so I might open a PR instead

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to defer this. The code works for now, but I'd really like to work on boiling down some common functionality eventually -- something we can work out in the future.

@bergmeister bergmeister requested a review from JamesWTruher March 5, 2019 21:41
Copy link
Contributor

@JamesWTruher JamesWTruher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@bergmeister bergmeister merged commit a68b139 into PowerShell:development Mar 8, 2019
bergmeister added a commit to bergmeister/PSScriptAnalyzer that referenced this pull request Mar 22, 2019
…erShell#1099)

* Fix Parsing of settings that occurs when using turkish culture

* use german culture before running tests to exhibit failures

* set ui culture as well

* fix communityanalyzer for turkish culture

* fix ProvideCommentHelp for turkish culture (i problem again)

* update comments

* fix for import-localizedDatabug in pscore (opened issue 8219 in ps core repo)

* change to UI culture

* use invariant culture comparison instead of tolowerinvariant and revert change where it is not needed

* finish with comments

* Use OrdinalIgnoreCase

* revert accidental change from 2 commits before

* trigger ci

* Apply suggestions from code review

Co-Authored-By: bergmeister <[email protected]>

* Use else-less approach to address PR comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue - Bug (Re-)Review Needed Feedback has been addressed during PR stage or is required in the first place.
Projects
None yet
3 participants