microsoft / CodeContracts

Source code for the CodeContracts tools for .NET
Other
882 stars 150 forks source link

Some possible defects (expression issues) #453

Open AppChecker opened 8 years ago

AppChecker commented 8 years ago

Good afternoon!

We've checked your source code with AppChecker static analyzer and found some possible defects:

1) Microsoft.Research/MetadataContracts/MetadataTracker.cs

if (lineText.Contains('(') && lineText.Contains('(') && lineText.Contains(';')) { //If method

Presence of symbol '(' is cheching twice. I guess it should be ')' second time

2) Microsoft.Research/ContractAdornments/CSharp.Roslyn/Inheritance/InheritanceTracker.cs#L233

if (!(@this._propertyKeys.Contains(tuple.Item1) && @this._propertyKeys.Contains(tuple.Item1)))

@this._propertyKeys.Contains(tuple.Item1) is checking twice. Maybe, tuple.Item2 should be checked

Same defect seems to be here - https://github.com/Microsoft/CodeContracts/blob/01e007bc7b2fbd11eb1418ed10d1e0d595195046/Microsoft.Research/ContractAdornments/CSharp/Inheritance/InheritanceTracker.cs#L233

3) System.Compiler/Reader.cs#L3968

if (modified == null || modified == null) return null;

modified is checking twice. Maybe, modifier must be checked instead

4) System.Compiler/Reader.cs#L2442

      if ((((MethodFlags)meth.Flags) & MethodFlags.SpecialName) != 0 &&
        (((MethodFlags)meth.Flags) & MethodFlags.SpecialName) != 0)

(((MethodFlags)meth.Flags) & MethodFlags.SpecialName) != 0 is checking twice

5) Microsoft.Research/ContractAdornments/CSharp.Roslyn/Contracts/ContractsProvider.cs#L714

if (semanticType.Name == null || semanticType.Name == null) goto ReturnFalse;

semanticType.Name is checking twice

Same defect seems to be here - https://github.com/Microsoft/CodeContracts/blob/01e007bc7b2fbd11eb1418ed10d1e0d595195046/Microsoft.Research/ContractAdornments/CSharp.Roslyn/Contracts/ContractsProvider.cs#L694

6) Microsoft.VisualStudio.CodeTools/TaskManager/Tool.cs#L128

if (buildTask != null && buildTask != null)

buildTask != null is checking twice

All possible defects were found by Echelon team with AppChecker static analyzer.

SergeyTeplyakov commented 8 years ago

Thanks a lot. They're definitely bugs!