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

Add test cases for all rules with relevant C# 9 syntax #3668

Closed
costin-zaharia-sonarsource opened this issue Oct 26, 2020 · 3 comments
Closed
Assignees
Milestone

Comments

@costin-zaharia-sonarsource
Copy link
Member

costin-zaharia-sonarsource commented Oct 26, 2020

Back in summer we've evaluated what rules need to be updated ("Implement"), or at least sanity-checked ("Add UT") in C#9 Affected rules.

We need to go one by one and add in the existing unit tests the C# 9 syntax we believe may affect these rules.

Important: in the C#9 Affected rules table, please change "Add UT" to "Implement" when you realize that something doesn't work out of the box.

  • highlight with yellow, to underline the need to implement has been confirmed when adding a UT
  • if, after adding the UTs, there's no need for an implementation, highlight "Add UT" with green (to know we did it)

image

  • S3442 AbstractTypesShouldNotHaveConstructors.cs
  • S4432 AesManagedShouldBeWithSecureMode.cs
  • S3244 AnonymousDelegateEventUnsubscribe.cs
  • S2330 ArrayCovariance.cs
  • S2306 AsyncAwaitIdentifier.cs
  • S3168 AsyncVoidMethod.cs
  • S1200 AvoidExcessiveClassCoupling.cs
  • S110 AvoidExcessiveInheritance.cs
  • S4583 BeginInvokePairedWithEndInvoke.cs
  • S3343 CallerInformationParametersShouldBeLast.cs
  • S4462 CallToAsyncMethodShouldNotBeBlocking.cs
  • S3247 CastShouldNotBeDuplicated.cs
  • S4830 CertificateValidationCheck.cs
  • S3928 CheckArgumentException.cs
  • S1451 CheckFileLicense.cs
  • S100, S101 ClassAndMethodName.cs
  • S3453 ClassNotInstantiatable.cs
  • S1694 ClassShouldNotBeAbstract.cs
  • S3897 ClassWithEqualityShouldImplementIEquatable.cs
  • S1118 ClassWithOnlyStaticMember.cs
  • S3776 CognitiveComplexity.cs
  • S4004 CollectionPropertiesShouldBeReadOnly.cs
  • S2971 CollectionQuerySimplification.cs
  • S3240 ConditionalSimplification.cs
  • S1862 ConditionalStructureSameCondition.cs
  • S2760 ConditionalsWithSameCondition.cs
  • S2583, S2589 ConditionEvaluatesToConstant.cs
  • S4260 ConstructorArgumentValueShouldExist.cs
  • S3330 CookieShouldBeHttpOnly.cs
  • S2092 CookieShouldBeSecure.cs
  • S4426 CryptographicKeyShouldNotBeTooShort.cs
  • S3869 DangerousGetHandleShouldNotBeCalled.cs
  • S1854 DeadStores.cs
  • S3346 DebugAssertHasNoSideEffects.cs
  • S3903 DeclareTypesInNamespaces.cs
  • S4524 DefaultSectionShouldBeFirstOrLast.cs
  • S3172 DelegateSubtraction.cs
  • S2931 DisposableMemberInNonDisposableClass.cs
  • S2930 DisposableNotDisposed.cs
  • S2997 DisposableReturnedFromUsing.cs
  • S4002 DisposableTypesNeedFinalizers.cs
  • S2952 DisposeFromDispose.cs
  • S2953 DisposeNotImplementingDispose.cs
  • S3902 DoNotCallAssemblyGetExecutingAssemblyMethod.cs
  • S3885 DoNotCallAssemblyLoadInvalidMethods.cs
  • S1147 DoNotCallExitMethods.cs
  • S1215 DoNotCallGCCollectMethod.cs
  • S3971 DoNotCallGCSuppressFinalizeMethod.cs
  • S1696 DoNotCatchNullReferenceException.cs
  • S2221 DoNotCatchSystemException.cs
  • S3981 DoNotCheckZeroSizeCollection.cs
  • S2365 DoNotCopyArraysInProperties.cs
  • S4015 DoNotDecreaseMemberVisibility.cs
  • S3956 DoNotExposeListT.cs
  • S4019 DoNotHideBaseClassMethods.cs
  • S2183 DoNotShiftByZeroOrIntSize.cs
  • S3060 DoNotTestThisWithIsOperator.cs
  • S1048 DoNotThrowFromDestructors.cs
  • S3874 DoNotUseOutRefParameters.cs
  • S881 DontMixIncrementOrDecrementWithOtherOperators.cs
  • S3875 DotNotOverloadOperatorEqual.cs
  • S1186 EmptyMethod.cs
  • S1116 EmptyStatement.cs
  • S2291 EnumerableSumInUnchecked.cs
  • S2197 EqualityOnModulus.cs
  • S4035 EquatableClassShouldBeSealed.cs
  • S4220 EventHandlerDelegateShouldHaveProperArguments.cs
  • S3877 ExceptionShouldNotBeThrownFromUnexpectedMethods.cs
  • S1067 ExpressionComplexity.cs
  • S4226 ExtensionMethodShouldBeInSeparateNamespace.cs
  • S2387, S4025 FieldShadowsParentField.cs
  • S2933 FieldShouldBeReadonly.cs
  • S2357 FieldShouldNotBePublic.cs
  • S1104 FieldsShouldNotBePublic.cs
  • S3880 FinalizerShouldNotBeEmpty.cs
  • S1541 FunctionComplexity.cs
  • S134 FunctionNestingDepth.cs
  • S3464 GenericInheritanceShouldNotBeRecursive.cs
  • S2934 GenericReadonlyFieldPropertyAssignment.cs
  • S2955 GenericTypeParameterEmptinessChecking.cs
  • S2326 GenericTypeParameterUnused.cs
  • S3249 GetHashCodeEqualsOverride.cs
  • S2328 GetHashCodeMutable.cs
  • S2219 GetTypeWithIsAssignableFrom.cs
  • S3397 GuardConditionOnEqualsOverride.cs
  • S3881 ImplementIDisposableCorrectly.cs
  • S3925 ImplementISerializableCorrectly.cs
  • S3927 ImplementSerializationMethodsCorrectly.cs
  • S3973 IndentSingleLineFollowingConditional.cs
  • S5766 InsecureDeserialization.cs
  • S2278, S5547 InsecureEncryptionAlgorithm.cs
  • S2070 InsecureHashAlgorithm.cs
  • S4039 InterfaceMethodsShouldBeCallableByChildTypes.cs
  • S3220 InvocationResolvesToOverrideWithParams.cs
  • S1309 IssueSuppression.cs
  • S5659 JwtSigned.cs
  • S4433 LdapConnectionShouldBeSecure.cs
  • S4055 LiteralsShouldNotBePassedAsLocalizedParameters.cs
  • S2184 LossOfFractionInDivision.cs
  • S4210 MarkWindowsFormsMainWithStaThread.cs
  • S3052 MemberInitializedToDefault.cs
  • S3604 MemberInitializerRedundant.cs
  • S1185 MemberOverrideCallsBaseMember.cs
  • S3218 MemberShadowsOuterStaticMember.cs
  • S2325 MemberShouldBeStatic.cs
  • S3427 MethodOverloadOptionalParameter.cs
  • S4136 MethodOverloadsShouldBeGrouped.cs
  • S3600 MethodOverrideAddsParams.cs
  • S1006 MethodOverrideChangedDefaultValue.cs
  • S3262 MethodOverrideNoParams.cs
  • S3450 MethodParameterMissingOptional.cs
  • S1172 MethodParameterUnused.cs
  • S4144 MethodsShouldNotHaveIdenticalImplementations.cs
  • S138 MethodsShouldNotHaveTooManyLines.cs
  • S3242 MethodsShouldUseBaseTypes.cs
  • S4200 NativeMethodsShouldBeWrapped.cs
  • S1199 NestedCodeBlock.cs
  • S3459 NotAssignedPrivateMember.cs
  • S3937 NumberPatternShouldBeRegular.cs
  • S1123 ObsoleteAttributesNeedExplanation.cs
  • S4069 OperatorOverloadsShouldHaveNamedAlternatives.cs
  • S4050 OperatorsShouldBeOverloadedConsistently.cs
  • S3466 OptionalParameterNotPassedToBaseCall.cs
  • S3447 OptionalRefOutParameter.cs
  • S1206 OverrideGetHashCodeOnOverridingEquals.cs
  • S1226 ParameterAssignedTo.cs
  • S927 ParameterNamesInPartialMethod.cs
  • S4428 PartCreationPolicyShouldBeUsedWithExportAttribute.cs
  • S3251 PartialMethodNoImplementation.cs
  • S4214 PInvokesShouldNotBeVisible.cs
  • S4000 PointersShouldBePrivate.cs
  • S1450 PrivateFieldUsedAsLocalVariable.cs
  • S4275 PropertiesAccessCorrectField.cs
  • S4049 PropertiesShouldBePreferred.cs
  • S2292 PropertyToAutoProperty.cs
  • S2376 PropertyWriteOnly.cs
  • S3926 ProvideDeserializationMethodsForOptionalFields.cs
  • S2339 PublicConstantField.cs
  • S3603 PureAttributeOnVoidMethod.cs
  • S4829 ReadingStandardInput.cs
  • S3253 RedundancyInConstructorDestructorDeclaration.cs
  • S3254 RedundantArgument.cs
  • S3440 RedundantConditionalAroundAssignment.cs
  • S3257 RedundantDeclaration.cs
  • S1939 RedundantInheritanceList.cs
  • S3626 RedundantJumpStatement.cs
  • S2333 RedundantModifier.cs
  • S4201 RedundantNullCheck.cs
  • S3235 RedundantParenthesesObjectsCreation.cs
  • S1858 RedundantToStringCall.cs
  • S1168 ReturnEmptyCollectionInsteadOfNull.cs
  • S2201 ReturnValueIgnored.cs
  • S2757 ReversedOperators.cs
  • S4212 SerializationConstructorsShouldBeSecured.cs
  • S4057 SetLocaleForDataTypes.cs
  • S3449 ShiftDynamicNotInteger.cs
  • S4159 ShouldImplementExportedInterfaces.cs
  • S2437 SillyBitwiseOperation.cs
  • S122 SingleStatementPerLine.cs
  • S2743 StaticFieldInGenericClass.cs
  • S3263 StaticFieldInitializerOrder.cs
  • S2223 StaticFieldVisible.cs
  • S3010 StaticFieldWrittenFromInstanceConstructor.cs
  • S2696 StaticFieldWrittenFromInstanceMember.cs
  • S2156 StaticSealedClassProtectedMembers.cs
  • S1192 StringLiteralShouldNotBeDuplicated.cs
  • S3876 StringOrIntegralTypesForIndexers.cs
  • S3234 SuppressFinalizeUseless.cs
  • S3458 SwitchCaseFallsThroughToDefault.cs
  • S2187 TestClassShouldHaveTestMethod.cs
  • S2699 TestMethodShouldContainAssertion.cs
  • S3433 TestMethodShouldHaveCorrectSignature.cs
  • S1607 TestMethodShouldNotBeIgnored.cs
  • S3366 ThisShouldNotBeExposedFromConstructors.cs
  • S3005 ThreadStaticNonStaticField.cs
  • S2996 ThreadStaticWithInitializer.cs
  • S2436 TooManyGenericParameters.cs
  • S2225 ToStringNoNull.cs
  • S4041 TypeNamesShouldNotMatchNamespaces.cs
  • S4052 TypesShouldNotExtendOutdatedBaseTypes.cs
  • S2761 UnaryPrefixOperatorRepeated.cs
  • S3353 UnchangedLocalVariablesShouldBeConst.cs
  • S3264 UninvokedEventDeclaration.cs
  • S1128 UnnecessaryUsings.cs
  • S1144, S4487 UnusedPrivateMember.cs
  • S3241 UnusedReturnValue.cs
  • S3908 UseGenericEventHandlerInstances.cs
  • S4047 UseGenericWithRefParameters.cs
  • S2148 UseNumericLiteralSeparator.cs
  • S4061 UseParamsForVariableArguments.cs
  • S2178 UseShortCircuitingOperator.cs
  • S3994, S3995, S3996, S3997, S4005 UseUriInsteadOfString.cs
  • S3237 UseValueParameter.cs
  • S2123 ValuesUselesslyIncremented.cs
  • S1117 VariableShadowsField.cs
  • S1481 VariableUnused.cs
  • S2290 VirtualEventField.cs
  • S2755 XmlExternalEntityShouldNotBeParsed.cs
@andrei-epure-sonarsource andrei-epure-sonarsource added this to the 8.15 milestone Oct 26, 2020
@andrei-epure-sonarsource andrei-epure-sonarsource changed the title Add test cases for all rules with relevant C# 9 syntax -> excel file (To Split) Add test cases for all rules with relevant C# 9 syntax Oct 28, 2020
@pavel-mikula-sonarsource
Copy link
Contributor

I've moved - S1944 InvalidCastToInterface.cs, InvalidCastToInterfaceRuleConstants.cs, InvalidCastToInterfaceSymbolicExecution.cs to SE issue #3693

@AraHaan
Copy link

AraHaan commented Apr 10, 2022

I got to nit about S2333:

When using codacy production it throws this for code that uses partial for my tests as it splits it's contents into 3 separate files (removing like it suggests would result in compile error).

Not sure if it is flagged with latest version or if version 8.30 is the current latest.

@pavel-mikula-sonarsource
Copy link
Contributor

Hi @AraHaan, as this issue is closed, please create a new one with a reproducer. You can get the latest version by referencing NuGet package.

Please note that Codacy uses per-file analysis, therefore their scaffolding loses a lot of information. At least that was the case in the past.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants