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

Enhance check for assignment by rather checking if assigned variable is used in assignment block #1

Conversation

bergmeister
Copy link
Owner

@bergmeister bergmeister commented Feb 13, 2018

to avoid false positives for assignments: check if variable on LHS is used in statement block
update documentation and change level to warning since we are now much more certain that a violation. is happening

GetName(), DiagnosticSeverity.Information, fileName);
var statementBlockOfIfStatenent = clause.Item2;
var variableExpressionAstsInStatementBlockOfIfStatement = statementBlockOfIfStatenent.FindAll(testAst => testAst is VariableExpressionAst, searchNestedScriptBlocks: true);
if (variableExpressionAstsInStatementBlockOfIfStatement == null) // no variable uages
Copy link
Owner Author

@bergmeister bergmeister Feb 13, 2018

Choose a reason for hiding this comment

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

typo in comment

@bergmeister bergmeister changed the title Warn pipeline inside if statement enhanced prototype Enhance check for assignment by rather checking if assigned variable is used in assignment block Feb 17, 2018
@bergmeister
Copy link
Owner Author

all tests pass locally now. will merge

@bergmeister bergmeister merged commit 8a48a62 into WarnPipelineInsideIfStatement Feb 17, 2018
bergmeister pushed a commit that referenced this pull request Mar 1, 2019
* Add compatibilty rule serialization types

* Move compatibility checking code into submodule

* Create module manifest, change module base dir name

* Move module to new file, change namespaces

* Add submodule binplace dir to .gitignore

* Delete binary files

* Fix up lsb info function

* Fixup module, correct names and namespaces

* Remove debugger wait

* Improve architecture handling

* Clean up serialization API

* Improve module filtering

* Partial work on query API

* Add more query types

* Update query API, move enums to common

* Add assembly name to type accelerator dictionary

* Add reference to compatibility project in pssa

* Add new command compatibility rule

* Add deep clone, basic rule implementation

* Make profiles multi-platform

* Fix Platform type name usage

* Add intersection logic

* Change to ICloneable, add some union functionality

* More union implementation

* Finish union logic

* Add combinator methods

* Fix profile creation, add combinator cmdlet

* Fix intersection logic, module versioning

* Fix various NREs, try to improve profile combination

* Replace IDictionary with JsonDictionary

* Change build target properly

* Fix broken namespace and build version

* Get output from intersection command

* TODO about intersection

* Fix version intersections

* Add profiles to the committed assets

* Add function to generate any_profile config

* Revert net452 change in order to build

* Make profiles single-platform, enable multiple targets

* Hook rule into testing

* Fix string resources

* Hook cross compat up to first test

* Add custom diagnostic type for compatibility checking

* Begin fixing case sensitivity

* Fix case sensitivity in profile union

* Fix platform property, make test pass

* Add singleton for performance, change tests to test cases

* Add cache clear method for profile loader

* enable building on non-Windows to not target .Net Framework by default (#1)

* Make PSScriptAnalyzer build independent of CrossCompatibility build

* Fix dll path issue in psm1

* Add ubuntu 18.04 profiles

* Fix root module, fix type names, powershell version may be string

* Make script compatible with PSv3

* Fix v3 compat, add union profile name, begin version work

* Add PowerShellVersion class

* Change PowerShell json to new version type, add test build

* Add documentation for UseCompatibleCmdlets2

* Remove PS from configuration example

* Fix versions + build merge problem, start typename fix

* Serialize type names correctly

* Make function exports explicit

* Fix psd1, add type name normalization functions

* Fix name normalization, add type query logic, genericize compatibility rules, add skeleton for type compatibility rule

* Fix type query building bug, rename command compat rule, begin type compat rule

* Build out type compatibility check rule

* Use simple typename expansion

* Remove unused test assets, add scaffold for type tests, change platform naming to include dotnet details

* Fix alias glitch, add native commands, move type conversion api

* Add better profiles, add native command tracking, fix union and build

* Add union profile, move AzF profile out of folder

* Move analysis exception to new file/namespace

* Add -Clean to build script

* Use new ending for profile extension

* Use new structure for native commands

* Add more command tests, fix GAC ignorance in profiler module

* Fix bugs in profile script, add validation function

* Fix profiler bugs, remove old profiles

* Ignore lack of profile dir

* Omit edition on lower PS versions

* Add new profiles, remove intersection logic, fix unions

* Add IDs to profiles for later union autogeneration

* Make profile loader more threadsafe

* Use net452-compatible hashset logic

* Fudge over type compilation bug

* Add types tests, fix command param parsing, fix attribute parsing

* Update documentation, add types test

* Add copyright headers

* Add some doc comments - more to come

* Add simple syntax compatibility rule

* Add workflow checking

* Remove parallel and sequence linting

* update .net core version in README.md to match global.json

* The engine project does not need a reference to the crosscompat project since the Rules project has this already

* Remove example file

* Fix safe expression evaluation in settings parser

* Remove bad debug code

* Update language in gitignore

* Add proper resource strings

* Make tests pass

* Remove unneeded bits

* Add MEF attributes

* Fix executable name problem

* Use correct report summary switch

* Fix test bugs

* Tweaks to failing tests

* Add documentation comments to C#

* Remove violations error write in test

* Add debug to csproj const properties

* Simplify build macros in the hope that they work now

* Make profile cache case insensitive

* Add PSV3/4 flags to debug configurations

* Improve new-object correction syntax

* Add tests for and fix up GetSafeValue implementation

* Move to autogenerated union files

* Quote paths for testing, add exception to alias tests, remove unused regex

* Add command parameter and static type member checking

* Enforce readonly nature of platform object

* Fix bugs in code and test

* Write union profile out on creation

* Add ignore settings for command and type compatibility rules

* Add more testing, fix bugs, renew profiles

* Detect dynamic method invocation for ps3 compatibility

* Move from PLINQ to tasks

* Take out nonfix in command rule, fix build script syntax problem

* Fix profile union, type compat bugs, add type compat tests

* Add script test for compatible commands

* Add tests for compatible syntax rule

* Add repo-facing tests for UseCompatibleSyntax

* Temp test to see ubuntu problem

* Fix ubuntu date alias test

* Fix test failure in PSv3/4

* Make new error messages into resource strings

* Add newtonsoft.json manually in old old powershell versions

* Filter diagnostics to omit parse errors

* Fix last PSv3/4 specific test

* Use better compile-time macro

* Get rid of verbose logging of activator instantiation

* Turn LINQ into lazy static methods

* Fix NRE in types, move command query tables to lazy methods

* Add CrossCompatibility to AppVeyor build and test

* Prevent trying to reload CrossCompatibility.dll

* Add Windows SKU enum to platform query object

* Fix problems with CC module in AppVeyor path

* More probing

* Fix CC build condition

* Add FX to build script params

* Attempt to fix Dll binplace issue

* Fix typename logic

* Fix EOL in files

* Remove unused LINQ calls

* Address some of @JamesWTruher's feedback

* Better way to get common parameters

* Address more of @JamesWTruher's feedback

* Address @bergmeister's add-type feedback

* Address pipe usage, nasty foreach

* Profiles bundled as a ZIP file

* Ignore zip type in build file

* Ensure zip functions are present

* Change name of cross compat assembly

* Add cross compat asm to signing

* Address more of @JamesWTruher's feedback

* Fix build path bug

* Make some profiles optional, improve compat rule docs

* Add documentation

* Remove defunct anyplatform name

* Add exclusion parameters to cc module

* Add parameter documentation

* Fix automatic variable detection

* Add explicit default case

* Fix tests for fewer rules

* Fix type compat test profile bugs

* Fix compatibility module bug

* Add path exclusions to module

* Fix linux pscustomobject problem

* Fix profile module bugs, update profiles

* Update documentation for profile names

* Rename module and sign

* Fix build name bug

* Upgrade docket .NET version

* Ignore clean error

* Add verbose message to release script

* Verbose hack

* Remove verbose

* Tweak out copy

* Fix signing xml

* Fix signing XML

* Correct framework signing to net452

* Remove AuthenticodeDual

* Update signing for PSCompatibilityAnalyzer

* Update VSCode search exclusion for profiles

* Fix loading problem in PowerShell 5

* Fix Add-Type Newtonsoft in PS 5

* Add missing copyright headers

* Add other copyright headers
bergmeister pushed a commit that referenced this pull request Mar 5, 2019
* Add compatibilty rule serialization types

* Move compatibility checking code into submodule

* Create module manifest, change module base dir name

* Move module to new file, change namespaces

* Add submodule binplace dir to .gitignore

* Delete binary files

* Fix up lsb info function

* Fixup module, correct names and namespaces

* Remove debugger wait

* Improve architecture handling

* Clean up serialization API

* Improve module filtering

* Partial work on query API

* Add more query types

* Update query API, move enums to common

* Add assembly name to type accelerator dictionary

* Add reference to compatibility project in pssa

* Add new command compatibility rule

* Add deep clone, basic rule implementation

* Make profiles multi-platform

* Fix Platform type name usage

* Add intersection logic

* Change to ICloneable, add some union functionality

* More union implementation

* Finish union logic

* Add combinator methods

* Fix profile creation, add combinator cmdlet

* Fix intersection logic, module versioning

* Fix various NREs, try to improve profile combination

* Replace IDictionary with JsonDictionary

* Change build target properly

* Fix broken namespace and build version

* Get output from intersection command

* TODO about intersection

* Fix version intersections

* Add profiles to the committed assets

* Add function to generate any_profile config

* Revert net452 change in order to build

* Make profiles single-platform, enable multiple targets

* Hook rule into testing

* Fix string resources

* Hook cross compat up to first test

* Add custom diagnostic type for compatibility checking

* Begin fixing case sensitivity

* Fix case sensitivity in profile union

* Fix platform property, make test pass

* Add singleton for performance, change tests to test cases

* Add cache clear method for profile loader

* enable building on non-Windows to not target .Net Framework by default (#1)

* Make PSScriptAnalyzer build independent of CrossCompatibility build

* Fix dll path issue in psm1

* Add ubuntu 18.04 profiles

* Fix root module, fix type names, powershell version may be string

* Make script compatible with PSv3

* Fix v3 compat, add union profile name, begin version work

* Add PowerShellVersion class

* Change PowerShell json to new version type, add test build

* Add documentation for UseCompatibleCmdlets2

* Remove PS from configuration example

* Fix versions + build merge problem, start typename fix

* Serialize type names correctly

* Make function exports explicit

* Fix psd1, add type name normalization functions

* Fix name normalization, add type query logic, genericize compatibility rules, add skeleton for type compatibility rule

* Fix type query building bug, rename command compat rule, begin type compat rule

* Build out type compatibility check rule

* Use simple typename expansion

* Remove unused test assets, add scaffold for type tests, change platform naming to include dotnet details

* Fix alias glitch, add native commands, move type conversion api

* Add better profiles, add native command tracking, fix union and build

* Add union profile, move AzF profile out of folder

* Move analysis exception to new file/namespace

* Add -Clean to build script

* Use new ending for profile extension

* Use new structure for native commands

* Add more command tests, fix GAC ignorance in profiler module

* Fix bugs in profile script, add validation function

* Fix profiler bugs, remove old profiles

* Ignore lack of profile dir

* Omit edition on lower PS versions

* Add new profiles, remove intersection logic, fix unions

* Add IDs to profiles for later union autogeneration

* Make profile loader more threadsafe

* Use net452-compatible hashset logic

* Fudge over type compilation bug

* Add types tests, fix command param parsing, fix attribute parsing

* Update documentation, add types test

* Add copyright headers

* Add some doc comments - more to come

* Add simple syntax compatibility rule

* Add workflow checking

* Remove parallel and sequence linting

* update .net core version in README.md to match global.json

* The engine project does not need a reference to the crosscompat project since the Rules project has this already

* Remove example file

* Fix safe expression evaluation in settings parser

* Remove bad debug code

* Update language in gitignore

* Add proper resource strings

* Make tests pass

* Remove unneeded bits

* Add MEF attributes

* Fix executable name problem

* Use correct report summary switch

* Fix test bugs

* Tweaks to failing tests

* Add documentation comments to C#

* Remove violations error write in test

* Add debug to csproj const properties

* Simplify build macros in the hope that they work now

* Make profile cache case insensitive

* Add PSV3/4 flags to debug configurations

* Improve new-object correction syntax

* Add tests for and fix up GetSafeValue implementation

* Move to autogenerated union files

* Quote paths for testing, add exception to alias tests, remove unused regex

* Add command parameter and static type member checking

* Enforce readonly nature of platform object

* Fix bugs in code and test

* Write union profile out on creation

* Add ignore settings for command and type compatibility rules

* Add more testing, fix bugs, renew profiles

* Detect dynamic method invocation for ps3 compatibility

* Move from PLINQ to tasks

* Take out nonfix in command rule, fix build script syntax problem

* Fix profile union, type compat bugs, add type compat tests

* Add script test for compatible commands

* Add tests for compatible syntax rule

* Add repo-facing tests for UseCompatibleSyntax

* Temp test to see ubuntu problem

* Fix ubuntu date alias test

* Fix test failure in PSv3/4

* Make new error messages into resource strings

* Add newtonsoft.json manually in old old powershell versions

* Filter diagnostics to omit parse errors

* Fix last PSv3/4 specific test

* Use better compile-time macro

* Get rid of verbose logging of activator instantiation

* Turn LINQ into lazy static methods

* Fix NRE in types, move command query tables to lazy methods

* Add CrossCompatibility to AppVeyor build and test

* Prevent trying to reload CrossCompatibility.dll

* Add Windows SKU enum to platform query object

* Fix problems with CC module in AppVeyor path

* More probing

* Fix CC build condition

* Add FX to build script params

* Attempt to fix Dll binplace issue

* Fix typename logic

* Fix EOL in files

* Remove unused LINQ calls

* Address some of @JamesWTruher's feedback

* Better way to get common parameters

* Address more of @JamesWTruher's feedback

* Address @bergmeister's add-type feedback

* Address pipe usage, nasty foreach

* Profiles bundled as a ZIP file

* Ignore zip type in build file

* Ensure zip functions are present

* Change name of cross compat assembly

* Add cross compat asm to signing

* Address more of @JamesWTruher's feedback

* Fix build path bug

* Make some profiles optional, improve compat rule docs

* Add documentation

* Remove defunct anyplatform name

* Add exclusion parameters to cc module

* Add parameter documentation

* Fix automatic variable detection

* Add explicit default case

* Fix tests for fewer rules

* Fix type compat test profile bugs

* Fix compatibility module bug

* Add path exclusions to module

* Fix linux pscustomobject problem

* Fix profile module bugs, update profiles

* Update documentation for profile names

* Rename module and sign

* Fix build name bug

* Upgrade docket .NET version

* Ignore clean error

* Add verbose message to release script

* Verbose hack

* Remove verbose

* Tweak out copy

* Fix signing xml

* Fix signing XML

* Correct framework signing to net452

* Remove AuthenticodeDual

* Update signing for PSCompatibilityAnalyzer

* Update VSCode search exclusion for profiles

* Fix loading problem in PowerShell 5

* Fix Add-Type Newtonsoft in PS 5

* Add missing copyright headers

* Add other copyright headers
bergmeister pushed a commit that referenced this pull request Mar 22, 2019
* Add compatibilty rule serialization types

* Move compatibility checking code into submodule

* Create module manifest, change module base dir name

* Move module to new file, change namespaces

* Add submodule binplace dir to .gitignore

* Delete binary files

* Fix up lsb info function

* Fixup module, correct names and namespaces

* Remove debugger wait

* Improve architecture handling

* Clean up serialization API

* Improve module filtering

* Partial work on query API

* Add more query types

* Update query API, move enums to common

* Add assembly name to type accelerator dictionary

* Add reference to compatibility project in pssa

* Add new command compatibility rule

* Add deep clone, basic rule implementation

* Make profiles multi-platform

* Fix Platform type name usage

* Add intersection logic

* Change to ICloneable, add some union functionality

* More union implementation

* Finish union logic

* Add combinator methods

* Fix profile creation, add combinator cmdlet

* Fix intersection logic, module versioning

* Fix various NREs, try to improve profile combination

* Replace IDictionary with JsonDictionary

* Change build target properly

* Fix broken namespace and build version

* Get output from intersection command

* TODO about intersection

* Fix version intersections

* Add profiles to the committed assets

* Add function to generate any_profile config

* Revert net452 change in order to build

* Make profiles single-platform, enable multiple targets

* Hook rule into testing

* Fix string resources

* Hook cross compat up to first test

* Add custom diagnostic type for compatibility checking

* Begin fixing case sensitivity

* Fix case sensitivity in profile union

* Fix platform property, make test pass

* Add singleton for performance, change tests to test cases

* Add cache clear method for profile loader

* enable building on non-Windows to not target .Net Framework by default (#1)

* Make PSScriptAnalyzer build independent of CrossCompatibility build

* Fix dll path issue in psm1

* Add ubuntu 18.04 profiles

* Fix root module, fix type names, powershell version may be string

* Make script compatible with PSv3

* Fix v3 compat, add union profile name, begin version work

* Add PowerShellVersion class

* Change PowerShell json to new version type, add test build

* Add documentation for UseCompatibleCmdlets2

* Remove PS from configuration example

* Fix versions + build merge problem, start typename fix

* Serialize type names correctly

* Make function exports explicit

* Fix psd1, add type name normalization functions

* Fix name normalization, add type query logic, genericize compatibility rules, add skeleton for type compatibility rule

* Fix type query building bug, rename command compat rule, begin type compat rule

* Build out type compatibility check rule

* Use simple typename expansion

* Remove unused test assets, add scaffold for type tests, change platform naming to include dotnet details

* Fix alias glitch, add native commands, move type conversion api

* Add better profiles, add native command tracking, fix union and build

* Add union profile, move AzF profile out of folder

* Move analysis exception to new file/namespace

* Add -Clean to build script

* Use new ending for profile extension

* Use new structure for native commands

* Add more command tests, fix GAC ignorance in profiler module

* Fix bugs in profile script, add validation function

* Fix profiler bugs, remove old profiles

* Ignore lack of profile dir

* Omit edition on lower PS versions

* Add new profiles, remove intersection logic, fix unions

* Add IDs to profiles for later union autogeneration

* Make profile loader more threadsafe

* Use net452-compatible hashset logic

* Fudge over type compilation bug

* Add types tests, fix command param parsing, fix attribute parsing

* Update documentation, add types test

* Add copyright headers

* Add some doc comments - more to come

* Add simple syntax compatibility rule

* Add workflow checking

* Remove parallel and sequence linting

* update .net core version in README.md to match global.json

* The engine project does not need a reference to the crosscompat project since the Rules project has this already

* Remove example file

* Fix safe expression evaluation in settings parser

* Remove bad debug code

* Update language in gitignore

* Add proper resource strings

* Make tests pass

* Remove unneeded bits

* Add MEF attributes

* Fix executable name problem

* Use correct report summary switch

* Fix test bugs

* Tweaks to failing tests

* Add documentation comments to C#

* Remove violations error write in test

* Add debug to csproj const properties

* Simplify build macros in the hope that they work now

* Make profile cache case insensitive

* Add PSV3/4 flags to debug configurations

* Improve new-object correction syntax

* Add tests for and fix up GetSafeValue implementation

* Move to autogenerated union files

* Quote paths for testing, add exception to alias tests, remove unused regex

* Add command parameter and static type member checking

* Enforce readonly nature of platform object

* Fix bugs in code and test

* Write union profile out on creation

* Add ignore settings for command and type compatibility rules

* Add more testing, fix bugs, renew profiles

* Detect dynamic method invocation for ps3 compatibility

* Move from PLINQ to tasks

* Take out nonfix in command rule, fix build script syntax problem

* Fix profile union, type compat bugs, add type compat tests

* Add script test for compatible commands

* Add tests for compatible syntax rule

* Add repo-facing tests for UseCompatibleSyntax

* Temp test to see ubuntu problem

* Fix ubuntu date alias test

* Fix test failure in PSv3/4

* Make new error messages into resource strings

* Add newtonsoft.json manually in old old powershell versions

* Filter diagnostics to omit parse errors

* Fix last PSv3/4 specific test

* Use better compile-time macro

* Get rid of verbose logging of activator instantiation

* Turn LINQ into lazy static methods

* Fix NRE in types, move command query tables to lazy methods

* Add CrossCompatibility to AppVeyor build and test

* Prevent trying to reload CrossCompatibility.dll

* Add Windows SKU enum to platform query object

* Fix problems with CC module in AppVeyor path

* More probing

* Fix CC build condition

* Add FX to build script params

* Attempt to fix Dll binplace issue

* Fix typename logic

* Fix EOL in files

* Remove unused LINQ calls

* Address some of @JamesWTruher's feedback

* Better way to get common parameters

* Address more of @JamesWTruher's feedback

* Address @bergmeister's add-type feedback

* Address pipe usage, nasty foreach

* Profiles bundled as a ZIP file

* Ignore zip type in build file

* Ensure zip functions are present

* Change name of cross compat assembly

* Add cross compat asm to signing

* Address more of @JamesWTruher's feedback

* Fix build path bug

* Make some profiles optional, improve compat rule docs

* Add documentation

* Remove defunct anyplatform name

* Add exclusion parameters to cc module

* Add parameter documentation

* Fix automatic variable detection

* Add explicit default case

* Fix tests for fewer rules

* Fix type compat test profile bugs

* Fix compatibility module bug

* Add path exclusions to module

* Fix linux pscustomobject problem

* Fix profile module bugs, update profiles

* Update documentation for profile names

* Rename module and sign

* Fix build name bug

* Upgrade docket .NET version

* Ignore clean error

* Add verbose message to release script

* Verbose hack

* Remove verbose

* Tweak out copy

* Fix signing xml

* Fix signing XML

* Correct framework signing to net452

* Remove AuthenticodeDual

* Update signing for PSCompatibilityAnalyzer

* Update VSCode search exclusion for profiles

* Fix loading problem in PowerShell 5

* Fix Add-Type Newtonsoft in PS 5

* Add missing copyright headers

* Add other copyright headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant