MrData
  •  MrData
  • 62.6% (Friendly)
  • YAF Forumling Topic Starter
2009-10-11T06:48:10Z
Hello,

when I look over the code I found many things like this: if (text.Length > 0) or if(returnUrl == string.Empty) and so on. I use YAF with master pages as a part of an online game and sometimes I had the case that these strings were Null. To get my portal run, I fixed 3 or 4 of these issues with String.IsNullOrEmpty(). But I think that there are a lots of many other hidden issues in the code, they will come critical when someone not uses YAF as a standalone forum.
Do you know the FXCop tool from Microsoft? http://msdn.microsoft.com/en-us...ary/bb429476(VS.80).aspx  I used this tool over my assemblies and compiled pages to make my own code safer and stronger.

MrData
Sponsor
Jaben
  •  Jaben
  • 100% (Exalted)
  • YAF Developer
2009-10-11T12:19:58Z
I've run FxCop on the project. Never found it very useful, honestly. I agree the String.IsNullOrEmpty thing is an issue on the older code.

Telling me something need to get changed: :roll:
Providing a patch to me with the changes: :cheesy: :-d 8)

MrData
  •  MrData
  • 62.6% (Friendly)
  • YAF Forumling Topic Starter
2009-10-11T17:48:06Z
Ok, you are right, not all rules are useful :wink:
After the first run over all assebmlies an the compiled page the tool found over 14000 issues. Then I disabled a few rules :arrow: "only" 1500. As you can see in my analysis of the report file, the most problems came from Globalization rules

                  Issue count
TypeName                                  # of issues
SpecifyIFormatProvider                        727
DoNotInitializeUnnecessarily                  114
SpecifyCultureInfo                            107
DoNotCatchGeneralExceptionTypes                63
DoNotDeclareVisibleInstanceFields              57
TestForEmptyStringsUsingStringLength           47
SpecifyStringComparison                        41
DoNotRaiseReservedExceptionTypes               34
ReviewUnusedParameters                         34
UsePropertiesWhereAppropriate                  31
SetLocaleForDataTypes                          23
UseLiteralsWhereAppropriate                    20
DoNotExposeGenericLists                        19
DoNotCastUnnecessarily                         18
ConsiderPassingBaseTypesAsParameters           17
DoNotPassTypesByReference                      17
GenericMethodsShouldProvideTypeParameter       17
OperatorOverloadsHaveNamedAlternates           16
ImplementIDisposableCorrectly                  13
RemoveUnusedLocals                             13
AptcaMethodsShouldOnlyCallAptcaMethods         10
PropertiesShouldNotBeWriteOnly                 10
CollectionPropertiesShouldBeReadOnly            8
EventsShouldNotHaveBeforeOrAfterPrefix          8
CallGCSuppressFinalizeCorrectly                 7
ParameterNamesShouldMatchBaseDeclaration        7
NonConstantFieldsShouldNotBeVisible             6
PropertiesShouldNotReturnArrays                 5
AvoidUncalledPrivateCode                        4
DoNotIgnoreMethodResults                        4
InterfaceMethodsShouldBeCallableByChildTyp      4
DoNotHardcodeLocaleSpecificStrings              3
ReviewVisibleEventHandlers                      3
UseEventsWhereAppropriate                       3
AvoidOutParameters                              2
AvoidUnusedPrivateFields                        2
DeclareEventHandlersCorrectly                   2
DoNotDeclareReadOnlyMutableReferenceTypes       2
DoNotDeclareStaticMembersOnGenericTypes         2
OverrideLinkDemandsShouldBeIdenticalToBase      2
PropertyNamesShouldNotMatchGetMethods           2
DoNotCallOverridableMethodsInConstructors       1
IdentifiersShouldHaveCorrectSuffix              1
InitializeReferenceTypeStaticFieldsInline       1
MembersShouldNotExposeCertainConcreteTypes      1
Total for YAF                                1528


Give me 3 months of hollidays, stop your developement of YAF and I will make a very big patch :lol: 😛 :lol:


Sorry I can not upload the report file in this forum
Jaben
  •  Jaben
  • 100% (Exalted)
  • YAF Developer
2009-10-11T21:58:34Z
:lol:

Frankly, I'd rather you help improve the code other ways -- such as helping me clean up the .ascx.cs code pages and moving things into classes.

The culture is changed/specified for the whole page instance. Not sure why it would it need to be specified PER function call.

If anyone working on the project (me included) are going to spend 3 months doing something -- the payoff better be huge. 😲
MrData
  •  MrData
  • 62.6% (Friendly)
  • YAF Forumling Topic Starter
2009-10-12T15:04:32Z
I reduced the rule list again. The globalization warnings came mostly from toUpper() / toLower() calls. I have randomly checked this warnings, all came from harcoded strings.

As you can see in my bottom analysis, many warnings came from exception handling and then from string testing. I will not fix the exception handling, because one has to introduce a new YAFException class ...

Here you can download the report file (works only in IE correct) 

New analysis:
Issue count
TypeName                                  # issues
DoNotInitializeUnnecessarily                  114
DoNotCatchGeneralExceptionTypes                63
DoNotDeclareVisibleInstanceFields              57
TestForEmptyStringsUsingStringLength           47
DoNotRaiseReservedExceptionTypes               34
ReviewUnusedParameters                         34
UseLiteralsWhereAppropriate                    20
DoNotExposeGenericLists                        19
DoNotCastUnnecessarily                         18
ConsiderPassingBaseTypesAsParameters           17
ImplementIDisposableCorrectly                  13
RemoveUnusedLocals                             13
AptcaMethodsShouldOnlyCallAptcaMethods         10
PropertiesShouldNotBeWriteOnly                 10
CollectionPropertiesShouldBeReadOnly            8
CallGCSuppressFinalizeCorrectly                 7
NonConstantFieldsShouldNotBeVisible             6
PropertiesShouldNotReturnArrays                 5
AvoidUncalledPrivateCode                        4
DoNotIgnoreMethodResults                        4
InterfaceMethodsShouldBeCallableByChildTyp      4
DoNotHardcodeLocaleSpecificStrings              3
ReviewVisibleEventHandlers                      3
UseEventsWhereAppropriate                       3
AvoidUnusedPrivateFields                        2
DeclareEventHandlersCorrectly                   2
DoNotDeclareReadOnlyMutableReferenceTypes       2
DoNotDeclareStaticMembersOnGenericTypes         2
OverrideLinkDemandsShouldBeIdenticalToBase      2
DoNotCallOverridableMethodsInConstructors       1
InitializeReferenceTypeStaticFieldsInline       1
MembersShouldNotExposeCertainConcreteTypes      1
=================================================
Total                                         529

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved