It is recommended to use the NDepend interactive UI capabilities
to make the most of NDepend by mastering all aspects of your code.
Diagrams
Application Metrics
Note: Further Application Statistics are available.
|
Rules summary
101353This section lists all Rules violated, and Rules or Queries with Error- Number of Rules or Queries with Error (syntax error, exception thrown, time-out): 0
- Number of Rules violated: 38
Summary of Rules violated

development-time, from within Visual
Studio. Online documentation.

existing code base? Use the option
Recent Violations Only!

can be used to break the build process if
violated. Online documentation.
Application Statistics
Stat | # Occurences | Avg | StdDev | Max |
---|---|---|---|---|
Properties on interfaces | 15 interfaces | 2.6 | 1.08 | 4 properties on ColorMine.ColorSpaces.ICmyk |
Methods on interfaces | 15 interfaces | 5.53 | 1.5 | 8 methods on ColorMine.ColorSpaces.ICmyk |
Arguments on methods on interfaces | 83 methods | 0.53 | 0.55 | 2 arguments on ColorMine.ColorSpaces.IColorSpace.Compare(IColorSpace,IColorSpaceComparison) |
Public properties on classes | 72 Classes | 0.54 | 1.17 | 4 public properties on ColorMine.ColorSpaces.Cmyk |
Public methods on classes | 72 classes | 4.39 | 5.5 | 37 public methods on ColorMine.Test.ColorSpaces.RgbTest+To |
Arguments on public methods on classes | 316 methods | 0.28 | 0.61 | 4 arguments on ColorMine.ColorSpaces.ComparisonAlgorithm.BeginInvoke(IColorSpace,IColorSpace,AsyncCallback,Object) |
IL instructions in non-abstract methods | 393 methods | 27.02 | 36.17 | 461 IL instructions in ColorMine.ColorSpaces.Comparisons.CieDe2000Comparison.Compare(IColorSpace,IColorSpace) |
Cyclomatic complexity on non abstract Methods | 393 Methods | 1.27 | 1.24 | CC = 15 for ColorMine.ColorSpaces.Comparisons.CieDe2000Comparison.Compare(IColorSpace,IColorSpace) |
Assemblies Metrics
Clicking column header arrows sorts values.
Clicking column header title text redirect to the online Code Metric definition.
Assemblies | # lines of code | # IL instruction | # Types | # Abstract Types | # lines of comment | % Comment | % Coverage | Afferent Coupling | Efferent Coupling | Relational Cohesion | Instability | Abstractness | Distance |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ColorMine v1.0.0.0 | 400 | 3891 | 59 | 16 | 165 | 29 | - | 19 | 29 | 2.92 | 0.6 | 0.27 | 0.09 |
ColorMine.Test v1.0.0.0 | 489 | 6726 | 36 | 1 | 31 | 5 | - | 0 | 54 | 0.89 | 1 | 0.03 | 0.02 |
If you wish to define thresholds on types' Code Metrics, consider writing some Rule.
Clicking column header arrows sorts values.
Clicking column header title text redirect to the online Code Metric definition.
Types Metrics : Code Quality
Type Name | Type Rank | # Lines Of Code | # IL Instructions | # Lines Of Comment | % Comment | Cyclomatic Complexity | IL Cyclomatic Complexity | % Coverage | Afferent Coupling | Efferent Coupling | Type Namespace |
---|---|---|---|---|---|---|---|---|---|---|---|
IColorSpace | 15.43 | - | - | 22 | 100 | 0 | - | - | 52 | 4 | ColorMine.ColorSpaces |
IRgb | 8.26 | - | - | 0 | - | 0 | - | - | 41 | 3 | ColorMine.ColorSpaces |
IColorSpaceComparison | 4.8 | - | - | 6 | 100 | 0 | - | - | 10 | 2 | ColorMine.ColorSpaces.Comparisons |
ColorSpace | 2.84 | 6 | 52 | 11 | 64.71 | 3 | 7 | - | 19 | 10 | ColorMine.ColorSpaces |
Rgb | 1.69 | 2 | 46 | 0 | 0 | 2 | 9 | - | 21 | 8 | ColorMine.ColorSpaces |
Lab | 1.63 | 2 | 46 | 0 | 0 | 2 | 9 | - | 20 | 9 | ColorMine.ColorSpaces |
Xyz | 1.35 | 2 | 46 | 0 | 0 | 2 | 9 | - | 17 | 9 | ColorMine.ColorSpaces |
IXyz | 1.35 | - | - | 0 | - | 0 | - | - | 16 | 3 | ColorMine.ColorSpaces |
ILab | 1.07 | - | - | 0 | - | 0 | - | - | 14 | 3 | ColorMine.ColorSpaces |
IHsl | 1.07 | - | - | 0 | - | 0 | - | - | 14 | 3 | ColorMine.ColorSpaces |
Cie94Comparison+Application | 1.06 | - | - | 0 | - | 0 | - | - | 5 | 4 | ColorMine.ColorSpaces.Comparisons |
DoubleExtension | 1.01 | 2 | 22 | 0 | 0 | 2 | 2 | - | 8 | 5 | ColorMine.ColorSpaces.Conversions .Utility |
ICmy | 1 | - | - | 0 | - | 0 | - | - | 13 | 3 | ColorMine.ColorSpaces |
ICmyk | 0.99 | - | - | 0 | - | 0 | - | - | 15 | 3 | ColorMine.ColorSpaces |
IYxy | 0.94 | - | - | 0 | - | 0 | - | - | 13 | 3 | ColorMine.ColorSpaces |
ILch | 0.92 | - | - | 0 | - | 0 | - | - | 13 | 3 | ColorMine.ColorSpaces |
IHsb | 0.89 | - | - | 0 | - | 0 | - | - | 12 | 3 | ColorMine.ColorSpaces |
Hsl | 0.8 | 2 | 46 | 0 | 0 | 2 | 9 | - | 12 | 9 | ColorMine.ColorSpaces |
Cmyk | 0.77 | 2 | 56 | 0 | 0 | 2 | 11 | - | 13 | 9 | ColorMine.ColorSpaces |
ColorSpaceTest | 0.75 | 51 | 1265 | 3 | 5.56 | 13 | 14 | - | 11 | 32 | ColorMine.Test.ColorSpaces |
Cmy | 0.74 | 2 | 46 | 0 | 0 | 2 | 9 | - | 12 | 9 | ColorMine.ColorSpaces |
Cie94Comparison+ApplicationConstants | 0.7 | 10 | 67 | 0 | 0 | 3 | 10 | - | 3 | 5 | ColorMine.ColorSpaces.Comparisons |
Yxy | 0.67 | 2 | 46 | 0 | 0 | 2 | 9 | - | 11 | 9 | ColorMine.ColorSpaces |
Lch | 0.67 | 2 | 46 | 0 | 0 | 2 | 9 | - | 11 | 9 | ColorMine.ColorSpaces |
Cie94ComparisonTest+ApplicationConstants +ApplicationConstantsConstructor | 0.64 | 4 | 23 | 0 | 0 | 2 | 3 | - | 2 | 5 | ColorMine.Test.ColorSpaces.Comparisons |
Hsb | 0.62 | 2 | 46 | 0 | 0 | 2 | 9 | - | 10 | 9 | ColorMine.ColorSpaces |
ILuv | 0.6 | - | - | 0 | - | 0 | - | - | 7 | 3 | ColorMine.ColorSpaces |
XyzConverter | 0.58 | 25 | 273 | 5 | 16.67 | 12 | 19 | - | 3 | 10 | ColorMine.ColorSpaces.Conversions |
IHunterLab | 0.45 | - | - | 0 | - | 0 | - | - | 4 | 3 | ColorMine.ColorSpaces |
HsbTest+To | 0.45 | 27 | 349 | - | - | - | 10 | - | 1 | 23 | ColorMine.Test.ColorSpaces |
LabTest+To | 0.45 | 24 | 311 | - | - | - | 9 | - | 1 | 21 | ColorMine.Test.ColorSpaces |
LchTest+To | 0.45 | 27 | 349 | - | - | - | 10 | - | 1 | 23 | ColorMine.Test.ColorSpaces |
XyzTest+To | 0.45 | 27 | 349 | - | - | - | 10 | - | 1 | 23 | ColorMine.Test.ColorSpaces |
DoubleExtensionTest+BasicallyEqualTo | 0.45 | 4 | 33 | 0 | 0 | 4 | 5 | - | 1 | 5 | ColorMine.Test.Utility |
CmykTest+To | 0.45 | 27 | 385 | - | - | - | 10 | - | 1 | 23 | ColorMine.Test.ColorSpaces |
CmyTest+To | 0.45 | 30 | 387 | - | - | - | 11 | - | 1 | 25 | ColorMine.Test.ColorSpaces |
LuvTest+To | 0.45 | 30 | 387 | - | - | - | 11 | - | 1 | 25 | ColorMine.Test.ColorSpaces |
CieDe2000ComparisonTest+Compare | 0.45 | 21 | 193 | 0 | 0 | 9 | 14 | - | 1 | 25 | ColorMine.Test.ColorSpaces.Comparisons |
HslTest+To | 0.45 | 27 | 349 | - | - | - | 10 | - | 1 | 23 | ColorMine.Test.ColorSpaces |
HsvTest+To | 0.45 | 30 | 387 | - | - | - | 11 | - | 1 | 26 | ColorMine.Test.ColorSpaces |
CmcComparisonTest+Compare | 0.45 | 15 | 189 | 4 | 21.05 | 5 | 6 | - | 1 | 10 | ColorMine.Test.ColorSpaces.Comparisons |
Cie1976ComparisonTest+Compare | 0.45 | 15 | 133 | 3 | 16.67 | 4 | 5 | - | 1 | 12 | ColorMine.Test.ColorSpaces.Comparisons |
RgbTest+To | 0.45 | 108 | 1383 | - | - | - | 37 | - | 1 | 29 | ColorMine.Test.ColorSpaces |
HunterLabTest+To | 0.45 | 6 | 79 | - | - | - | 3 | - | 1 | 10 | ColorMine.Test.ColorSpaces |
HslConverter | 0.44 | 32 | 247 | 1 | 3.03 | 12 | 16 | - | 2 | 11 | ColorMine.ColorSpaces.Conversions |
IHsv | 0.44 | - | - | 0 | - | 0 | - | - | 4 | 3 | ColorMine.ColorSpaces |
RgbConverter | 0.43 | 4 | 23 | 0 | 0 | 2 | 2 | - | 1 | 4 | ColorMine.ColorSpaces.Conversions |
Cie94Comparison | 0.41 | 21 | 168 | 16 | 43.24 | 5 | 9 | - | 2 | 10 | ColorMine.ColorSpaces.Comparisons |
LabConverter | 0.39 | 19 | 188 | 0 | 0 | 8 | 12 | - | 1 | 10 | ColorMine.ColorSpaces.Conversions |
Luv | 0.37 | 2 | 46 | 0 | 0 | 2 | 9 | - | 5 | 9 | ColorMine.ColorSpaces |
CmykConverter | 0.36 | 38 | 299 | 0 | 0 | 11 | 14 | - | 2 | 16 | ColorMine.ColorSpaces.Conversions |
IColorSpaceWithProfile | 0.36 | - | - | 0 | - | 0 | - | - | 2 | 3 | ColorMine.ColorSpaces |
HunterLab | 0.35 | 2 | 46 | 0 | 0 | 2 | 9 | - | 3 | 9 | ColorMine.ColorSpaces |
CmyConverter | 0.31 | 4 | 64 | 0 | 0 | 2 | 2 | - | 1 | 6 | ColorMine.ColorSpaces.Conversions |
Cie94ComparisonTest+Compare | 0.3 | 6 | 64 | 2 | 25 | 2 | 3 | - | 1 | 11 | ColorMine.Test.ColorSpaces.Comparisons |
Cie94ComparisonTest+Cie94ComparisonConst ructor | 0.3 | 10 | 60 | 0 | 0 | 2 | 3 | - | 1 | 6 | ColorMine.Test.ColorSpaces.Comparisons |
Cie94ComparisonTest+ApplicationConstants | 0.3 | 0 | 3 | 0 | - | 0 | 1 | - | 1 | 3 | ColorMine.Test.ColorSpaces.Comparisons |
YxyConverter | 0.3 | 9 | 109 | 0 | 0 | 4 | 6 | - | 1 | 9 | ColorMine.ColorSpaces.Conversions |
LchConverter | 0.3 | 15 | 129 | 1 | 6.25 | 5 | 6 | - | 1 | 11 | ColorMine.ColorSpaces.Conversions |
HsbConverter | 0.29 | 7 | 49 | 0 | 0 | 2 | 2 | - | 1 | 8 | ColorMine.ColorSpaces.Conversions |
Hsv | 0.28 | 2 | 46 | 0 | 0 | 2 | 9 | - | 3 | 9 | ColorMine.ColorSpaces |
LuvConverter | 0.27 | 24 | 240 | 2 | 7.69 | 7 | 11 | - | 1 | 9 | ColorMine.ColorSpaces.Conversions |
HunterLabConverter | 0.27 | 10 | 120 | 0 | 0 | 4 | 6 | - | 1 | 10 | ColorMine.ColorSpaces.Conversions |
CmcComparison | 0.26 | 25 | 221 | 14 | 35.9 | 7 | 8 | - | 1 | 7 | ColorMine.ColorSpaces.Comparisons |
HsvConverter | 0.26 | 21 | 200 | 0 | 0 | 13 | 18 | - | 1 | 11 | ColorMine.ColorSpaces.Conversions |
Cie1976Comparison | 0.25 | 5 | 46 | 3 | 37.5 | 2 | 3 | - | 1 | 7 | ColorMine.ColorSpaces.Comparisons |
CmykProfileConverter | 0.22 | 29 | 223 | 0 | 0 | 3 | 5 | - | 1 | 23 | ColorMine.ColorSpaces.Conversions |
ColorSpaceWithProfile | 0.2 | 0 | 23 | 0 | - | 0 | 5 | - | 1 | 6 | ColorMine.ColorSpaces |
CieDe2000Comparison | 0.2 | 56 | 474 | 11 | 16.42 | 10 | 17 | - | 1 | 8 | ColorMine.ColorSpaces.Comparisons |
CmykProfileConverter+RgbColor | 0.19 | 0 | 0 | 0 | - | 0 | 0 | - | 1 | 3 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+FileShare | 0.19 | - | - | 0 | - | 0 | - | - | 1 | 4 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+CmykColor | 0.19 | 0 | 0 | 0 | - | 0 | 0 | - | 1 | 3 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+ColorTransformMode | 0.19 | - | - | 0 | - | 0 | - | - | 1 | 4 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+ColorType | 0.19 | - | - | 0 | - | 0 | - | - | 1 | 4 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+ProfileFilename | 0.19 | 4 | 20 | 0 | 0 | 1 | 1 | - | 1 | 5 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+LogicalColorSpace | 0.19 | - | - | 0 | - | 0 | - | - | 1 | 4 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+CreateDisposition | 0.19 | - | - | 0 | - | 0 | - | - | 1 | 4 | ColorMine.ColorSpaces.Conversions |
ColorSpaceExtensions | 0.15 | 10 | 72 | 0 | 0 | 4 | 5 | - | 0 | 17 | ColorMine.ColorSpaces |
Cie1976ComparisonTest | 0.15 | 0 | 3 | 0 | - | 0 | 1 | - | 0 | 3 | ColorMine.Test.ColorSpaces.Comparisons |
HunterLabTest | 0.15 | 0 | 3 | - | - | - | 1 | - | 0 | 3 | ColorMine.Test.ColorSpaces |
HsvTest | 0.15 | 0 | 3 | - | - | - | 1 | - | 0 | 3 | ColorMine.Test.ColorSpaces |
LuvTest | 0.15 | 0 | 3 | - | - | - | 1 | - | 0 | 3 | ColorMine.Test.ColorSpaces |
XyzTest | 0.15 | 0 | 3 | - | - | - | 1 | - | 0 | 3 | ColorMine.Test.ColorSpaces |
CmcComparisonTest | 0.15 | 0 | 3 | 0 | - | 0 | 1 | - | 0 | 3 | ColorMine.Test.ColorSpaces.Comparisons |
LchTest | 0.15 | 0 | 3 | - | - | - | 1 | - | 0 | 3 | ColorMine.Test.ColorSpaces |
LabTest | 0.15 | 0 | 3 | - | - | - | 1 | - | 0 | 3 | ColorMine.Test.ColorSpaces |
HsbTest | 0.15 | 0 | 3 | - | - | - | 1 | - | 0 | 3 | ColorMine.Test.ColorSpaces |
DoubleExtensionTest | 0.15 | 0 | 3 | 0 | - | 0 | 1 | - | 0 | 3 | ColorMine.Test.Utility |
HslTest | 0.15 | 0 | 3 | - | - | - | 1 | - | 0 | 3 | ColorMine.Test.ColorSpaces |
Cie94ComparisonTest | 0.15 | 0 | 3 | 0 | - | 0 | 1 | - | 0 | 6 | ColorMine.Test.ColorSpaces.Comparisons |
CmykTest | 0.15 | 0 | 3 | - | - | - | 1 | - | 0 | 3 | ColorMine.Test.ColorSpaces |
CieDe2000ComparisonTest | 0.15 | 0 | 3 | 0 | - | 0 | 1 | - | 0 | 3 | ColorMine.Test.ColorSpaces.Comparisons |
CmyTest | 0.15 | 0 | 3 | - | - | - | 1 | - | 0 | 3 | ColorMine.Test.ColorSpaces |
RgbTest | 0.15 | 0 | 3 | - | - | - | 1 | - | 0 | 3 | ColorMine.Test.ColorSpaces |
ComparisonAlgorithm | 0.15 | - | - | - | - | - | - | - | 0 | 8 | ColorMine.ColorSpaces |
Types Metrics : Code Members and Inheritance
Type Name | # Instance Methods | Nb Static Methods | Nb Properties | # Fields | # Children Classes | Depth Of Inheritance Tree | Type Namespace |
---|---|---|---|---|---|---|---|
IColorSpace | 4 | 0 | 0 | 0 | - | - | ColorMine.ColorSpaces |
IRgb | 6 | 0 | 3 | 0 | - | - | ColorMine.ColorSpaces |
IColorSpaceComparison | 1 | 0 | 0 | 0 | - | - | ColorMine.ColorSpaces.Comparisons |
ColorSpace | 5 | 0 | 0 | 0 | 12 | 1 | ColorMine.ColorSpaces |
Rgb | 9 | 0 | 3 | 3 | 0 | 2 | ColorMine.ColorSpaces |
Lab | 9 | 0 | 3 | 3 | 0 | 2 | ColorMine.ColorSpaces |
Xyz | 9 | 0 | 3 | 3 | 0 | 2 | ColorMine.ColorSpaces |
IXyz | 6 | 0 | 3 | 0 | - | - | ColorMine.ColorSpaces |
ILab | 6 | 0 | 3 | 0 | - | - | ColorMine.ColorSpaces |
IHsl | 6 | 0 | 3 | 0 | - | - | ColorMine.ColorSpaces |
Cie94Comparison+Application | - | - | - | - | - | - | ColorMine.ColorSpaces.Comparisons |
DoubleExtension | 0 | 2 | 0 | 1 | 0 | 1 | ColorMine.ColorSpaces.Conversions .Utility |
ICmy | 6 | 0 | 3 | 0 | - | - | ColorMine.ColorSpaces |
ICmyk | 8 | 0 | 4 | 0 | - | - | ColorMine.ColorSpaces |
IYxy | 6 | 0 | 3 | 0 | - | - | ColorMine.ColorSpaces |
ILch | 6 | 0 | 3 | 0 | - | - | ColorMine.ColorSpaces |
IHsb | 6 | 0 | 3 | 0 | - | - | ColorMine.ColorSpaces |
Hsl | 9 | 0 | 3 | 3 | 0 | 2 | ColorMine.ColorSpaces |
Cmyk | 11 | 0 | 4 | 4 | 0 | 2 | ColorMine.ColorSpaces |
ColorSpaceTest | 1 | 13 | 0 | 0 | 11 | 1 | ColorMine.Test.ColorSpaces |
Cmy | 9 | 0 | 3 | 3 | 0 | 2 | ColorMine.ColorSpaces |
Cie94Comparison+ApplicationConstants | 7 | 0 | 3 | 3 | 0 | 1 | ColorMine.ColorSpaces.Comparisons |
Yxy | 9 | 0 | 3 | 3 | 0 | 2 | ColorMine.ColorSpaces |
Lch | 9 | 0 | 3 | 3 | 0 | 2 | ColorMine.ColorSpaces |
Cie94ComparisonTest+ApplicationConstants +ApplicationConstantsConstructor | 3 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
Hsb | 9 | 0 | 3 | 3 | 0 | 2 | ColorMine.ColorSpaces |
ILuv | 6 | 0 | 3 | 0 | - | - | ColorMine.ColorSpaces |
XyzConverter | 0 | 8 | 1 | 3 | 0 | 1 | ColorMine.ColorSpaces.Conversions |
IHunterLab | 6 | 0 | 3 | 0 | - | - | ColorMine.ColorSpaces |
HsbTest+To | 10 | 0 | 0 | 0 | 0 | 2 | ColorMine.Test.ColorSpaces |
LabTest+To | 9 | 0 | 0 | 0 | 0 | 2 | ColorMine.Test.ColorSpaces |
LchTest+To | 10 | 0 | 0 | 0 | 0 | 2 | ColorMine.Test.ColorSpaces |
XyzTest+To | 10 | 0 | 0 | 0 | 0 | 2 | ColorMine.Test.ColorSpaces |
DoubleExtensionTest+BasicallyEqualTo | 5 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.Utility |
CmykTest+To | 10 | 0 | 0 | 0 | 0 | 2 | ColorMine.Test.ColorSpaces |
CmyTest+To | 11 | 0 | 0 | 0 | 0 | 2 | ColorMine.Test.ColorSpaces |
LuvTest+To | 11 | 0 | 0 | 0 | 0 | 2 | ColorMine.Test.ColorSpaces |
CieDe2000ComparisonTest+Compare | 6 | 0 | 1 | 1 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
HslTest+To | 10 | 0 | 0 | 0 | 0 | 2 | ColorMine.Test.ColorSpaces |
HsvTest+To | 11 | 0 | 0 | 0 | 0 | 2 | ColorMine.Test.ColorSpaces |
CmcComparisonTest+Compare | 6 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
Cie1976ComparisonTest+Compare | 5 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
RgbTest+To | 37 | 0 | 0 | 0 | 0 | 2 | ColorMine.Test.ColorSpaces |
HunterLabTest+To | 3 | 0 | 0 | 0 | 0 | 2 | ColorMine.Test.ColorSpaces |
HslConverter | 0 | 4 | 0 | 0 | 0 | 1 | ColorMine.ColorSpaces.Conversions |
IHsv | 6 | 0 | 3 | 0 | - | - | ColorMine.ColorSpaces |
RgbConverter | 0 | 2 | 0 | 0 | 0 | 1 | ColorMine.ColorSpaces.Conversions |
Cie94Comparison | 5 | 0 | 1 | 1 | 0 | 1 | ColorMine.ColorSpaces.Comparisons |
LabConverter | 0 | 4 | 0 | 0 | 0 | 1 | ColorMine.ColorSpaces.Conversions |
Luv | 9 | 0 | 3 | 3 | 0 | 2 | ColorMine.ColorSpaces |
CmykConverter | 0 | 5 | 0 | 0 | 0 | 1 | ColorMine.ColorSpaces.Conversions |
IColorSpaceWithProfile | 4 | 0 | 2 | 0 | - | - | ColorMine.ColorSpaces |
HunterLab | 9 | 0 | 3 | 3 | 0 | 2 | ColorMine.ColorSpaces |
CmyConverter | 0 | 2 | 0 | 0 | 0 | 1 | ColorMine.ColorSpaces.Conversions |
Cie94ComparisonTest+Compare | 2 | 1 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
Cie94ComparisonTest+Cie94ComparisonConst ructor | 3 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
Cie94ComparisonTest+ApplicationConstants | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
YxyConverter | 0 | 2 | 0 | 0 | 0 | 1 | ColorMine.ColorSpaces.Conversions |
LchConverter | 0 | 2 | 0 | 0 | 0 | 1 | ColorMine.ColorSpaces.Conversions |
HsbConverter | 0 | 2 | 0 | 0 | 0 | 1 | ColorMine.ColorSpaces.Conversions |
Hsv | 9 | 0 | 3 | 3 | 0 | 2 | ColorMine.ColorSpaces |
LuvConverter | 0 | 3 | 0 | 0 | 0 | 1 | ColorMine.ColorSpaces.Conversions |
HunterLabConverter | 0 | 2 | 0 | 0 | 0 | 1 | ColorMine.ColorSpaces.Conversions |
CmcComparison | 3 | 1 | 0 | 4 | 0 | 1 | ColorMine.ColorSpaces.Comparisons |
HsvConverter | 0 | 5 | 0 | 0 | 0 | 1 | ColorMine.ColorSpaces.Conversions |
Cie1976Comparison | 2 | 1 | 0 | 0 | 0 | 1 | ColorMine.ColorSpaces.Comparisons |
CmykProfileConverter | 1 | 8 | 0 | 9 | 0 | 1 | ColorMine.ColorSpaces.Conversions |
ColorSpaceWithProfile | 5 | 0 | 2 | 2 | 0 | 1 | ColorMine.ColorSpaces |
CieDe2000Comparison | 3 | 0 | 0 | 0 | 0 | 1 | ColorMine.ColorSpaces.Comparisons |
CmykProfileConverter+RgbColor | 0 | 0 | 0 | 4 | - | - | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+FileShare | - | - | - | - | - | - | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+CmykColor | 0 | 0 | 0 | 4 | - | - | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+ColorTransformMode | - | - | - | - | - | - | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+ColorType | - | - | - | - | - | - | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+ProfileFilename | 1 | 0 | 0 | 3 | 0 | 1 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+LogicalColorSpace | - | - | - | - | - | - | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+CreateDisposition | - | - | - | - | - | - | ColorMine.ColorSpaces.Conversions |
ColorSpaceExtensions | 0 | 2 | 0 | 0 | 0 | 1 | ColorMine.ColorSpaces |
Cie1976ComparisonTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
HunterLabTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
HsvTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
LuvTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
XyzTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
CmcComparisonTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
LchTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
LabTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
HsbTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
DoubleExtensionTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.Utility |
HslTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
Cie94ComparisonTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
CmykTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
CieDe2000ComparisonTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
CmyTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
RgbTest | 1 | 0 | 0 | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
ComparisonAlgorithm | 4 | 0 | 0 | 0 | 0 | 3 | ColorMine.ColorSpaces |
Types Metrics : Lack Of Cohesion Of Methods and Association Between Classes
Type Name | Lack Of Cohesion Of Methods | Lack Of Cohesion Of Methods HS | Association Between Classes | Type Namespace |
---|---|---|---|---|
IColorSpace | - | - | 0 | ColorMine.ColorSpaces |
IRgb | - | - | 0 | ColorMine.ColorSpaces |
IColorSpaceComparison | - | - | 0 | ColorMine.ColorSpaces.Comparisons |
ColorSpace | 0 | 0 | 7 | ColorMine.ColorSpaces |
Rgb | 0 | 0 | 3 | ColorMine.ColorSpaces |
Lab | 0 | 0 | 3 | ColorMine.ColorSpaces |
Xyz | 0 | 0 | 3 | ColorMine.ColorSpaces |
IXyz | - | - | 0 | ColorMine.ColorSpaces |
ILab | - | - | 0 | ColorMine.ColorSpaces |
IHsl | - | - | 0 | ColorMine.ColorSpaces |
Cie94Comparison+Application | - | - | 0 | ColorMine.ColorSpaces.Comparisons |
DoubleExtension | 0 | 0 | 1 | ColorMine.ColorSpaces.Conversions .Utility |
ICmy | - | - | 0 | ColorMine.ColorSpaces |
ICmyk | - | - | 0 | ColorMine.ColorSpaces |
IYxy | - | - | 0 | ColorMine.ColorSpaces |
ILch | - | - | 0 | ColorMine.ColorSpaces |
IHsb | - | - | 0 | ColorMine.ColorSpaces |
Hsl | 0 | 0 | 3 | ColorMine.ColorSpaces |
Cmyk | 0 | 0 | 3 | ColorMine.ColorSpaces |
ColorSpaceTest | 0 | 0 | 78 | ColorMine.Test.ColorSpaces |
Cmy | 0 | 0 | 3 | ColorMine.ColorSpaces |
Cie94Comparison+ApplicationConstants | 0 | 0 | 2 | ColorMine.ColorSpaces.Comparisons |
Yxy | 0 | 0 | 3 | ColorMine.ColorSpaces |
Lch | 0 | 0 | 3 | ColorMine.ColorSpaces |
Cie94ComparisonTest+ApplicationConstants +ApplicationConstantsConstructor | 0 | 0 | 4 | ColorMine.Test.ColorSpaces.Comparisons |
Hsb | 0 | 0 | 3 | ColorMine.ColorSpaces |
ILuv | - | - | 0 | ColorMine.ColorSpaces |
XyzConverter | 0 | 0 | 18 | ColorMine.ColorSpaces.Conversions |
IHunterLab | - | - | 0 | ColorMine.ColorSpaces |
HsbTest+To | 0 | 0 | 47 | ColorMine.Test.ColorSpaces |
LabTest+To | 0 | 0 | 42 | ColorMine.Test.ColorSpaces |
LchTest+To | 0 | 0 | 47 | ColorMine.Test.ColorSpaces |
XyzTest+To | 0 | 0 | 47 | ColorMine.Test.ColorSpaces |
DoubleExtensionTest+BasicallyEqualTo | 0 | 0 | 3 | ColorMine.Test.Utility |
CmykTest+To | 0 | 0 | 47 | ColorMine.Test.ColorSpaces |
CmyTest+To | 0 | 0 | 52 | ColorMine.Test.ColorSpaces |
LuvTest+To | 0 | 0 | 52 | ColorMine.Test.ColorSpaces |
CieDe2000ComparisonTest+Compare | 0 | 0 | 29 | ColorMine.Test.ColorSpaces.Comparisons |
HslTest+To | 0 | 0 | 47 | ColorMine.Test.ColorSpaces |
HsvTest+To | 0 | 0 | 56 | ColorMine.Test.ColorSpaces |
CmcComparisonTest+Compare | 0 | 0 | 9 | ColorMine.Test.ColorSpaces.Comparisons |
Cie1976ComparisonTest+Compare | 0 | 0 | 13 | ColorMine.Test.ColorSpaces.Comparisons |
RgbTest+To | 0 | 0 | 62 | ColorMine.Test.ColorSpaces |
HunterLabTest+To | 0 | 0 | 15 | ColorMine.Test.ColorSpaces |
HslConverter | 0 | 0 | 18 | ColorMine.ColorSpaces.Conversions |
IHsv | - | - | 0 | ColorMine.ColorSpaces |
RgbConverter | 0 | 0 | 6 | ColorMine.ColorSpaces.Conversions |
Cie94Comparison | 0 | 0 | 11 | ColorMine.ColorSpaces.Comparisons |
LabConverter | 0 | 0 | 21 | ColorMine.ColorSpaces.Conversions |
Luv | 0 | 0 | 3 | ColorMine.ColorSpaces |
CmykConverter | 0 | 0 | 29 | ColorMine.ColorSpaces.Conversions |
IColorSpaceWithProfile | - | - | 0 | ColorMine.ColorSpaces |
HunterLab | 0 | 0 | 3 | ColorMine.ColorSpaces |
CmyConverter | 0 | 0 | 13 | ColorMine.ColorSpaces.Conversions |
Cie94ComparisonTest+Compare | 0 | 0 | 10 | ColorMine.Test.ColorSpaces.Comparisons |
Cie94ComparisonTest+Cie94ComparisonConst ructor | 0 | 0 | 9 | ColorMine.Test.ColorSpaces.Comparisons |
Cie94ComparisonTest+ApplicationConstants | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
YxyConverter | 0 | 0 | 16 | ColorMine.ColorSpaces.Conversions |
LchConverter | 0 | 0 | 20 | ColorMine.ColorSpaces.Conversions |
HsbConverter | 0 | 0 | 15 | ColorMine.ColorSpaces.Conversions |
Hsv | 0 | 0 | 3 | ColorMine.ColorSpaces |
LuvConverter | 0 | 0 | 19 | ColorMine.ColorSpaces.Conversions |
HunterLabConverter | 0 | 0 | 16 | ColorMine.ColorSpaces.Conversions |
CmcComparison | 0.25 | 0.33 | 9 | ColorMine.ColorSpaces.Comparisons |
HsvConverter | 0 | 0 | 17 | ColorMine.ColorSpaces.Conversions |
Cie1976Comparison | 0 | 0 | 6 | ColorMine.ColorSpaces.Comparisons |
CmykProfileConverter | 0 | 0 | 29 | ColorMine.ColorSpaces.Conversions |
ColorSpaceWithProfile | 0 | 0 | 1 | ColorMine.ColorSpaces |
CieDe2000Comparison | 0 | 0 | 11 | ColorMine.ColorSpaces.Comparisons |
CmykProfileConverter+RgbColor | 0 | 0 | 0 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+FileShare | - | - | 0 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+CmykColor | 0 | 0 | 0 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+ColorTransformMode | - | - | 0 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+ColorType | - | - | 0 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+ProfileFilename | 0 | 0 | 2 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+LogicalColorSpace | - | - | 0 | ColorMine.ColorSpaces.Conversions |
CmykProfileConverter+CreateDisposition | - | - | 0 | ColorMine.ColorSpaces.Conversions |
ColorSpaceExtensions | 0 | 0 | 12 | ColorMine.ColorSpaces |
Cie1976ComparisonTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
HunterLabTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
HsvTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
LuvTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
XyzTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
CmcComparisonTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
LchTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
LabTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
HsbTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
DoubleExtensionTest | 0 | 0 | 1 | ColorMine.Test.Utility |
HslTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
Cie94ComparisonTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
CmykTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
CieDe2000ComparisonTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces.Comparisons |
CmyTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
RgbTest | 0 | 0 | 1 | ColorMine.Test.ColorSpaces |
ComparisonAlgorithm | - | - | 0 | ColorMine.ColorSpaces |
Namespaces Metrics
Clicking column header arrows sorts values.
Clicking column header title text redirect to the online Code Metric definition.
Namespaces | # lines of code | # IL instruction | # Types | # lines of comment | % Comment | % Coverage | Afferent Coupling | Efferent Coupling |
---|---|---|---|---|---|---|---|---|
ColorMine.ColorSpaces | 40 | 709 | 30 | 39 | 49 | - | 4 | 5 |
ColorMine.ColorSpaces.Comparisons | 117 | 976 | 7 | 66 | 36 | - | 2 | 3 |
ColorMine.ColorSpaces.Conversions | 241 | 2184 | 21 | 20 | 7 | - | 1 | 8 |
ColorMine.ColorSpaces.Conversions .Utility | 2 | 22 | 1 | 0 | 0 | - | 3 | 2 |
ColorMine.Test.Utility | 4 | 36 | 2 | 0 | 0 | - | 0 | 2 |
ColorMine.Test.ColorSpaces | 414 | 6013 | 23 | 3 | 0 | - | 0 | 2 |
ColorMine.Test.ColorSpaces.Comparisons | 71 | 677 | 11 | 9 | 11 | - | 0 | 8 |
670
Code Quality |
|
![]() | Rule warning: Quick summary of methods to refactor |
warnif count > 0 from m in JustMyCode.Methods where
// Code Metrics' definitions
m.NbLinesOfCode > 30 || // http://www.ndepend.com/Metrics.aspx#NbLinesOfCode
// We've commented # IL Instructions, because with LINQ syntax, a few lines of code can compile to hundreds of IL instructions.
// m.NbILInstructions > 200 || // http://www.ndepend.com/Metrics.aspx#NbILInstructions
m.CyclomaticComplexity > 20 || // http://www.ndepend.com/Metrics.aspx#CC
m.ILCyclomaticComplexity > 50 || // http://www.ndepend.com/Metrics.aspx#ILCC
m.ILNestingDepth > 5 || // http://www.ndepend.com/Metrics.aspx#ILNestingDepth
m.NbParameters > 5 || // http://www.ndepend.com/Metrics.aspx#NbParameters
m.NbVariables > 8 || // http://www.ndepend.com/Metrics.aspx#NbVariables
m.NbOverloads > 6 // http://www.ndepend.com/Metrics.aspx#NbOverloads
select new { m, m.NbLinesOfCode, m.NbILInstructions, m.CyclomaticComplexity,
m.ILCyclomaticComplexity, m.ILNestingDepth,
m.NbParameters, m.NbVariables, m.NbOverloads } View Code Query or Rule Body
21 methods matched
methods | # lines of code (LOC) | # IL instructions | Cyclomatic Complexity (CC) | IL Cyclomatic Complexity (ILCC) | IL Nesting Depth | # Parameters | # Variables | # Overloads | Full Name |
---|---|---|---|---|---|---|---|---|---|
Compare(IColorSpace,IColorSpace) | 17 | 136 | 3 | 5 | 1 | 2 | 15 | 1 | ColorMine.ColorSpaces.Comparisons .Cie94Comparison.Compare(IColorSpace ,IColorSpace) |
Compare(IColorSpace,IColorSpace) | 55 | 461 | 9 | 15 | 1 | 2 | 38 | 1 | ColorMine.ColorSpaces.Comparisons .CieDe2000Comparison.Compare(IColorSpace ,IColorSpace) |
Compare(IColorSpace,IColorSpace) | 17 | 185 | 4 | 5 | 2 | 2 | 15 | 1 | ColorMine.ColorSpaces.Comparisons .CmcComparison.Compare(IColorSpace ,IColorSpace) |
TranslateColor(IRgb,Uri,Uri) | 24 | 191 | 2 | 3 | 1 | 3 | 12 | 2 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter.TranslateColor (IRgb,Uri,Uri) |
CreateMultiProfileTransform(IntPtr[] ,UInt32,UInt32[],UInt32 ,CmykProfileConverter+ColorTransformMode ,UInt32) | 0 | 0 | N/A | 0 | 0 | 6 | 0 | 1 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter .CreateMultiProfileTransform(IntPtr[] ,UInt32,UInt32[],UInt32 ,CmykProfileConverter+ColorTransformMode ,UInt32) |
TranslateColors(IntPtr ,CmykProfileConverter+RgbColor[],UInt32 ,CmykProfileConverter+ColorType ,CmykProfileConverter+CmykColor[] ,CmykProfileConverter+ColorType) | 0 | 0 | N/A | 0 | 0 | 6 | 0 | 1 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter.TranslateColors (IntPtr,CmykProfileConverter+RgbColor[] ,UInt32,CmykProfileConverter+ColorType ,CmykProfileConverter+CmykColor[] ,CmykProfileConverter+ColorType) |
ToColor(IHsl) | 15 | 117 | 4 | 6 | 2 | 1 | 9 | 1 | ColorMine.ColorSpaces.Conversions .HslConverter.ToColor(IHsl) |
ToColor(ILuv) | 12 | 126 | 2 | 3 | 1 | 1 | 12 | 1 | ColorMine.ColorSpaces.Conversions .LuvConverter.ToColor(ILuv) |
ExpectedValuesForKnownColor(IColorSpace ,ICmy) | 4 | 101 | 1 | 1 | 0 | 2 | 1 | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,ICmy) |
ExpectedValuesForKnownColor(IColorSpace ,ICmyk) | 5 | 133 | 1 | 1 | 0 | 2 | 1 | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,ICmyk) |
ExpectedValuesForKnownColor(IColorSpace ,IHsl) | 4 | 101 | 1 | 1 | 0 | 2 | 1 | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,IHsl) |
ExpectedValuesForKnownColor(IColorSpace ,IHsb) | 4 | 101 | 1 | 1 | 0 | 2 | 1 | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,IHsb) |
ExpectedValuesForKnownColor(IColorSpace ,ILab) | 4 | 101 | 1 | 1 | 0 | 2 | 1 | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,ILab) |
ExpectedValuesForKnownColor(IColorSpace ,ILch) | 4 | 101 | 1 | 1 | 0 | 2 | 1 | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,ILch) |
ExpectedValuesForKnownColor(IColorSpace ,IRgb) | 4 | 101 | 1 | 1 | 0 | 2 | 1 | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,IRgb) |
ExpectedValuesForKnownColor(IColorSpace ,IXyz) | 4 | 101 | 1 | 1 | 0 | 2 | 1 | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,IXyz) |
ExpectedValuesForKnownColor(IColorSpace ,IYxy) | 4 | 101 | 1 | 1 | 0 | 2 | 1 | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,IYxy) |
ExpectedValuesForKnownColor(IColorSpace ,ILuv) | 4 | 101 | 1 | 1 | 0 | 2 | 1 | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,ILuv) |
ExpectedValuesForKnownColor(IColorSpace ,IHsv) | 4 | 101 | 1 | 1 | 0 | 2 | 1 | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,IHsv) |
ExpectedValuesForKnownColor(IColorSpace ,IHunterLab) | 4 | 101 | 1 | 1 | 0 | 2 | 1 | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,IHunterLab) |
Initialize() | 13 | 119 | 6 | 5 | 2 | 0 | 9 | 1 | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest+Compare .Initialize() |
Statistics
Stat | # lines of code (LOC) | # IL instructions | Cyclomatic Complexity (CC) | IL Cyclomatic Complexity (ILCC) | IL Nesting Depth | # Parameters | # Variables | # Overloads |
---|---|---|---|---|---|---|---|---|
Sum: | 202 | 2 579 | 42 | 54 | 10 | 47 | 122 | 154 |
Average: | 9.62 | 122.81 | 2.21 | 2.57 | 0.48 | 2.24 | 5.81 | 7.33 |
Minimum: | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 |
Maximum: | 55 | 461 | 9 | 15 | 2 | 6 | 38 | 12 |
Standard deviation: | 11.9 | 86.91 | 2.12 | 3.29 | 0.73 | 1.34 | 8.86 | 5.39 |
Variance: | 141.66 | 7 553 | 4.48 | 10.82 | 0.54 | 1.8 | 78.44 | 29.08 |
![]() | Rule warning: Methods too big |
warnif count > 0 from m in JustMyCode.Methods where
m.NbLinesOfCode > 30
// We've commented # IL Instructions, because with LINQ syntax, a few lines of code can compile to hundreds of IL instructions.
// || m.NbILInstructions > 200
orderby m.NbLinesOfCode descending,
m.NbILInstructions descending
select new { m, m.NbLinesOfCode, m.NbILInstructions }
// Methods where NbLinesOfCode > 30 or NbILInstructions > 200
// are extremely complex and should be split in smaller methods.
// See the definition of the NbLinesOfCode metric here
// http://www.ndepend.com/Metrics.aspx#NbLinesOfCodeView Code Query or Rule Body
1 methods matched
method | # lines of code (LOC) | # IL instructions | Full Name |
---|---|---|---|
Compare(IColorSpace,IColorSpace) | 55 | 461 | ColorMine.ColorSpaces.Comparisons .CieDe2000Comparison.Compare(IColorSpace ,IColorSpace) |
Statistics
Stat | # lines of code (LOC) | # IL instructions |
---|---|---|
Sum: | 55 | 461 |
Average: | 55 | 461 |
Minimum: | 55 | 461 |
Maximum: | 55 | 461 |
Standard deviation: | 0 | 0 |
Variance: | 0 | 0 |
![]() | Rule warning: Methods potentially poorly commented |
warnif count > 0 from m in JustMyCode.Methods where
m.PercentageComment < 20 &&
m.NbLinesOfCode > 20
orderby m.PercentageComment ascending
select new { m, m.PercentageComment, m.NbLinesOfCode, m.NbLinesOfComment }
// Methods where %Comment < 20 and that have
// at least 20 lines of code might need to be more commented.
// See the definition of the Comments metric here
// http://www.ndepend.com/Metrics.aspx#PercentageComment
// http://www.ndepend.com/Metrics.aspx#NbLinesOfComment View Code Query or Rule Body
2 methods matched
methods | Percentage Comment | # lines of code (LOC) | # lines of comment | Full Name |
---|---|---|---|---|
TranslateColor(IRgb,Uri,Uri) | 0 | 24 | 0 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter.TranslateColor (IRgb,Uri,Uri) |
Compare(IColorSpace,IColorSpace) | 11 | 55 | 7 | ColorMine.ColorSpaces.Comparisons .CieDe2000Comparison.Compare(IColorSpace ,IColorSpace) |
Statistics
Stat | Percentage Comment | # lines of code (LOC) | # lines of comment |
---|---|---|---|
Sum: | 11 | 79 | 7 |
Average: | 5.5 | 39.5 | 3.5 |
Minimum: | 0 | 24 | 0 |
Maximum: | 11 | 55 | 7 |
Standard deviation: | 5.5 | 15.5 | 3.5 |
Variance: | 30.25 | 240.25 | 12.25 |
![]() | Rule warning: Methods with too many parameters |
warnif count > 0 from m in JustMyCode.Methods where
m.NbParameters > 5
orderby m.NbParameters descending
select new { m, m.NbParameters }
// Methods where NbParameters > 5 might be painful to call
// and might degrade performance. You should prefer using
// additional properties/fields to the declaring type to
// handle numerous states. Another alternative is to provide
// a class or structure dedicated to handle arguments passing
// (for example see the class System.Diagnostics.ProcessStartInfo
// and the method System.Diagnostics.Process.Start(ProcessStartInfo))
// See the definition of the NbParameters metric here
// http://www.ndepend.com/Metrics.aspx#NbParametersView Code Query or Rule Body
2 methods matched
methods | # Parameters | Full Name |
---|---|---|
CreateMultiProfileTransform(IntPtr[] ,UInt32,UInt32[],UInt32 ,CmykProfileConverter+ColorTransformMode ,UInt32) | 6 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter .CreateMultiProfileTransform(IntPtr[] ,UInt32,UInt32[],UInt32 ,CmykProfileConverter+ColorTransformMode ,UInt32) |
TranslateColors(IntPtr ,CmykProfileConverter+RgbColor[],UInt32 ,CmykProfileConverter+ColorType ,CmykProfileConverter+CmykColor[] ,CmykProfileConverter+ColorType) | 6 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter.TranslateColors (IntPtr,CmykProfileConverter+RgbColor[] ,UInt32,CmykProfileConverter+ColorType ,CmykProfileConverter+CmykColor[] ,CmykProfileConverter+ColorType) |
Statistics
Stat | # Parameters |
---|---|
Sum: | 12 |
Average: | 6 |
Minimum: | 6 |
Maximum: | 6 |
Standard deviation: | 0 |
Variance: | 0 |
![]() | Rule warning: Methods with too many local variables |
warnif count > 0 from m in JustMyCode.Methods where
m.NbVariables > 15
orderby m.NbVariables descending
select new { m, m.NbVariables }
// Methods where NbVariables > 8 are hard to understand and maintain.
// Methods where NbVariables > 15 are extremely complex
// and should be split in smaller methods.
// See the definition of the Nbvariables metric here
// http://www.ndepend.com/Metrics.aspx#NbvariablesView Code Query or Rule Body
1 methods matched
method | # Variables | Full Name |
---|---|---|
Compare(IColorSpace,IColorSpace) | 38 | ColorMine.ColorSpaces.Comparisons .CieDe2000Comparison.Compare(IColorSpace ,IColorSpace) |
Statistics
Stat | # Variables |
---|---|
Sum: | 38 |
Average: | 38 |
Minimum: | 38 |
Maximum: | 38 |
Standard deviation: | 0 |
Variance: | 0 |
![]() | Rule warning: Methods with too many overloads |
warnif count > 0 from m in JustMyCode.Methods where
m.NbOverloads > 6 &&
!m.IsOperator // Don't report operator overload
orderby m.NbOverloads descending
select new { m, m.NbOverloads }
// Methods where NbOverloads > 6 might
// be a problem to maintain and provoke higher coupling
// than necessary.
// This might also reveal a potential misused of the
// C# and VB.NET language that since C#3 and VB9 support
// object initialization. This feature helps reducing the number
// of constructors of a class.
// See the definition of the NbOverloads metric here
// http://www.ndepend.com/Metrics.aspx#NbOverloadsView Code Query or Rule Body
12 methods matched
methods | # Overloads | Full Name |
---|---|---|
ExpectedValuesForKnownColor(IColorSpace ,ICmy) | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,ICmy) |
ExpectedValuesForKnownColor(IColorSpace ,ICmyk) | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,ICmyk) |
ExpectedValuesForKnownColor(IColorSpace ,IHsl) | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,IHsl) |
ExpectedValuesForKnownColor(IColorSpace ,IHsb) | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,IHsb) |
ExpectedValuesForKnownColor(IColorSpace ,ILab) | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,ILab) |
ExpectedValuesForKnownColor(IColorSpace ,ILch) | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,ILch) |
ExpectedValuesForKnownColor(IColorSpace ,IRgb) | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,IRgb) |
ExpectedValuesForKnownColor(IColorSpace ,IXyz) | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,IXyz) |
ExpectedValuesForKnownColor(IColorSpace ,IYxy) | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,IYxy) |
ExpectedValuesForKnownColor(IColorSpace ,ILuv) | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,ILuv) |
ExpectedValuesForKnownColor(IColorSpace ,IHsv) | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,IHsv) |
ExpectedValuesForKnownColor(IColorSpace ,IHunterLab) | 12 | ColorMine.Test.ColorSpaces .ColorSpaceTest .ExpectedValuesForKnownColor(IColorSpace ,IHunterLab) |
Statistics
Stat | # Overloads |
---|---|
Sum: | 144 |
Average: | 12 |
Minimum: | 12 |
Maximum: | 12 |
Standard deviation: | 0 |
Variance: | 0 |
![]() | Rule warning: Types with too many methods |
warnif count > 0 from t in JustMyCode.Types where
t.Methods.Count() > 20
orderby t.Methods.Count() descending
select new { t, t.InstanceMethods, t.StaticMethods }
// Types where Methods.Count() > 20 might be hard to
// understand and maintain
// but there might be cases where it is relevant
// to have a high number of methods.
// For example, the System.Windows.Forms.DataGridView
// standard class has more than 1000 methods.
View Code Query or Rule Body
1 types matched
type | InstanceMethods | StaticMethods | Full Name |
---|---|---|---|
RgbTest+To | 36 methods | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To |
Statistics
Stat | InstanceMethods | StaticMethods |
---|---|---|
Sum: | 0 | 0 |
Average: | 0 | 0 |
Minimum: | 0 | 0 |
Maximum: | 0 | 0 |
Standard deviation: | 0 | 0 |
Variance: | 0 | 0 |
940
Object Oriented Design |
|
![]() | Rule warning: Class with no descendant should be sealed if possible |
warnif count > 0 from t in JustMyCode.Types where
t.IsClass &&
t.NbChildren ==0 &&
!t.IsSealed &&
!t.IsStatic
// && !t.IsPublic <-- You might want to add this condition
// if you are developing a framework
// with classes that are intended to be
// sub-classed by your clients.
orderby t.NbLinesOfCode descending
select new { t, t.NbLinesOfCode }View Code Query or Rule Body
55 types matched
types | # lines of code (LOC) | Full Name |
---|---|---|
RgbTest+To | 108 | ColorMine.Test.ColorSpaces.RgbTest+To |
CieDe2000Comparison | 56 | ColorMine.ColorSpaces.Comparisons .CieDe2000Comparison |
CmyTest+To | 30 | ColorMine.Test.ColorSpaces.CmyTest+To |
LuvTest+To | 30 | ColorMine.Test.ColorSpaces.LuvTest+To |
HsvTest+To | 30 | ColorMine.Test.ColorSpaces.HsvTest+To |
CmykProfileConverter | 29 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter |
CmykTest+To | 27 | ColorMine.Test.ColorSpaces.CmykTest+To |
HslTest+To | 27 | ColorMine.Test.ColorSpaces.HslTest+To |
HsbTest+To | 27 | ColorMine.Test.ColorSpaces.HsbTest+To |
LchTest+To | 27 | ColorMine.Test.ColorSpaces.LchTest+To |
XyzTest+To | 27 | ColorMine.Test.ColorSpaces.XyzTest+To |
CmcComparison | 25 | ColorMine.ColorSpaces.Comparisons .CmcComparison |
LabTest+To | 24 | ColorMine.Test.ColorSpaces.LabTest+To |
Cie94Comparison | 21 | ColorMine.ColorSpaces.Comparisons .Cie94Comparison |
CieDe2000ComparisonTest+Compare | 21 | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest+Compare |
CmcComparisonTest+Compare | 15 | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest+Compare |
Cie1976ComparisonTest+Compare | 15 | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest+Compare |
Cie94Comparison+ApplicationConstants | 10 | ColorMine.ColorSpaces.Comparisons .Cie94Comparison+ApplicationConstants |
Cie94ComparisonTest+Cie94ComparisonConst ructor | 10 | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Cie94ComparisonCons tructor |
HunterLabTest+To | 6 | ColorMine.Test.ColorSpaces .HunterLabTest+To |
Cie94ComparisonTest+Compare | 6 | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Compare |
Cie1976Comparison | 5 | ColorMine.ColorSpaces.Comparisons .Cie1976Comparison |
CmykProfileConverter+ProfileFilename | 4 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+ProfileFilename |
DoubleExtensionTest+BasicallyEqualTo | 4 | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo |
Cie94ComparisonTest+ApplicationConstants +ApplicationConstantsConstructor | 4 | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s+ApplicationConstantsConstructor |
Rgb | 2 | ColorMine.ColorSpaces.Rgb |
Xyz | 2 | ColorMine.ColorSpaces.Xyz |
Hsl | 2 | ColorMine.ColorSpaces.Hsl |
Lab | 2 | ColorMine.ColorSpaces.Lab |
Lch | 2 | ColorMine.ColorSpaces.Lch |
Luv | 2 | ColorMine.ColorSpaces.Luv |
Yxy | 2 | ColorMine.ColorSpaces.Yxy |
Cmy | 2 | ColorMine.ColorSpaces.Cmy |
Cmyk | 2 | ColorMine.ColorSpaces.Cmyk |
Hsv | 2 | ColorMine.ColorSpaces.Hsv |
Hsb | 2 | ColorMine.ColorSpaces.Hsb |
HunterLab | 2 | ColorMine.ColorSpaces.HunterLab |
ColorSpaceWithProfile | 0 | ColorMine.ColorSpaces .ColorSpaceWithProfile |
DoubleExtensionTest | 0 | ColorMine.Test.Utility .DoubleExtensionTest |
RgbTest | 0 | ColorMine.Test.ColorSpaces.RgbTest |
CmyTest | 0 | ColorMine.Test.ColorSpaces.CmyTest |
CmykTest | 0 | ColorMine.Test.ColorSpaces.CmykTest |
HslTest | 0 | ColorMine.Test.ColorSpaces.HslTest |
HsbTest | 0 | ColorMine.Test.ColorSpaces.HsbTest |
LabTest | 0 | ColorMine.Test.ColorSpaces.LabTest |
LchTest | 0 | ColorMine.Test.ColorSpaces.LchTest |
XyzTest | 0 | ColorMine.Test.ColorSpaces.XyzTest |
LuvTest | 0 | ColorMine.Test.ColorSpaces.LuvTest |
HsvTest | 0 | ColorMine.Test.ColorSpaces.HsvTest |
HunterLabTest | 0 | ColorMine.Test.ColorSpaces.HunterLabTest |
Cie94ComparisonTest | 0 | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest |
Cie94ComparisonTest+ApplicationConstants | 0 | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s |
CieDe2000ComparisonTest | 0 | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest |
CmcComparisonTest | 0 | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest |
Cie1976ComparisonTest | 0 | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest |
Statistics
Stat | # lines of code (LOC) |
---|---|
Sum: | 612 |
Average: | 11.13 |
Minimum: | 0 |
Maximum: | 108 |
Standard deviation: | 18.14 |
Variance: | 329.13 |
![]() | Rule warning: A stateless class or structure might be turned into a static type |
// This rule indicates stateless types that might
// eventually be turned into static classes.
warnif count > 0 from t in JustMyCode.Types where
!t.IsStatic &&
!t.IsGeneric &&
t.InstanceFields.Count() == 0 &&
// Don't match:
// --> types that implement some interfaces.
t.NbInterfacesImplemented == 0 &&
// --> or classes that have sub-classes children.
t.NbChildren == 0 &&
// --> or classes that have a base class
((t.IsClass && t.DepthOfDeriveFrom("System.Object".AllowNoMatch()) == 1) ||
t.IsStructure)
select t
View Code Query or Rule Body
24 types matched
types | Full Name |
---|---|
CmykProfileConverter | ColorMine.ColorSpaces.Conversions .CmykProfileConverter |
DoubleExtensionTest | ColorMine.Test.Utility .DoubleExtensionTest |
DoubleExtensionTest+BasicallyEqualTo | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo |
RgbTest | ColorMine.Test.ColorSpaces.RgbTest |
CmyTest | ColorMine.Test.ColorSpaces.CmyTest |
CmykTest | ColorMine.Test.ColorSpaces.CmykTest |
HslTest | ColorMine.Test.ColorSpaces.HslTest |
HsbTest | ColorMine.Test.ColorSpaces.HsbTest |
LabTest | ColorMine.Test.ColorSpaces.LabTest |
LchTest | ColorMine.Test.ColorSpaces.LchTest |
XyzTest | ColorMine.Test.ColorSpaces.XyzTest |
LuvTest | ColorMine.Test.ColorSpaces.LuvTest |
HsvTest | ColorMine.Test.ColorSpaces.HsvTest |
HunterLabTest | ColorMine.Test.ColorSpaces.HunterLabTest |
Cie94ComparisonTest | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest |
Cie94ComparisonTest+ApplicationConstants | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s |
Cie94ComparisonTest+ApplicationConstants +ApplicationConstantsConstructor | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s+ApplicationConstantsConstructor |
Cie94ComparisonTest+Cie94ComparisonConst ructor | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Cie94ComparisonCons tructor |
Cie94ComparisonTest+Compare | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Compare |
CieDe2000ComparisonTest | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest |
CmcComparisonTest | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest |
CmcComparisonTest+Compare | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest+Compare |
Cie1976ComparisonTest | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest |
Cie1976ComparisonTest+Compare | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest+Compare |
Statistics
Stat |
---|
Sum: |
Average: |
Minimum: |
Maximum: |
Standard deviation: |
Variance: |
![]() | Rule warning: Non-static classes should be instantiated or turned to static |
// Notice that classes only instantiated through reflection, like plug-in root classes
// are matched by this rules.
warnif count > 0
from t in JustMyCode.Types
where t.IsClass &&
//!t.IsPublic && // if you are developing a framework,
// you might not want to match public classes
!t.IsStatic &&
!t.IsAttributeClass && // Attributes class are never seen as instantiated
!t.DeriveFrom("System.MarshalByRefObject".AllowNoMatch()) // Types instantiated through remoting infrastructure
// find the first constructor of t called
let ctorCalled = t.Constructors.FirstOrDefault(ctor => ctor.NbMethodsCallingMe > 0)
// match t if none of its constructors is called.
where ctorCalled == null
select new { t, t.Visibility }View Code Query or Rule Body
36 types matched
types | Visibility | Full Name |
---|---|---|
CmykProfileConverter | Internal | ColorMine.ColorSpaces.Conversions .CmykProfileConverter |
DoubleExtensionTest | Public | ColorMine.Test.Utility .DoubleExtensionTest |
DoubleExtensionTest+BasicallyEqualTo | Public | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo |
RgbTest | Public | ColorMine.Test.ColorSpaces.RgbTest |
RgbTest+To | Public | ColorMine.Test.ColorSpaces.RgbTest+To |
CmyTest | Public | ColorMine.Test.ColorSpaces.CmyTest |
CmyTest+To | Public | ColorMine.Test.ColorSpaces.CmyTest+To |
CmykTest | Public | ColorMine.Test.ColorSpaces.CmykTest |
CmykTest+To | Public | ColorMine.Test.ColorSpaces.CmykTest+To |
HslTest | Public | ColorMine.Test.ColorSpaces.HslTest |
HslTest+To | Public | ColorMine.Test.ColorSpaces.HslTest+To |
HsbTest | Public | ColorMine.Test.ColorSpaces.HsbTest |
HsbTest+To | Public | ColorMine.Test.ColorSpaces.HsbTest+To |
LabTest | Public | ColorMine.Test.ColorSpaces.LabTest |
LabTest+To | Public | ColorMine.Test.ColorSpaces.LabTest+To |
LchTest | Public | ColorMine.Test.ColorSpaces.LchTest |
LchTest+To | Public | ColorMine.Test.ColorSpaces.LchTest+To |
XyzTest | Public | ColorMine.Test.ColorSpaces.XyzTest |
XyzTest+To | Public | ColorMine.Test.ColorSpaces.XyzTest+To |
LuvTest | Public | ColorMine.Test.ColorSpaces.LuvTest |
LuvTest+To | Public | ColorMine.Test.ColorSpaces.LuvTest+To |
HsvTest | Public | ColorMine.Test.ColorSpaces.HsvTest |
HsvTest+To | Public | ColorMine.Test.ColorSpaces.HsvTest+To |
HunterLabTest | Public | ColorMine.Test.ColorSpaces.HunterLabTest |
HunterLabTest+To | Public | ColorMine.Test.ColorSpaces .HunterLabTest+To |
Cie94ComparisonTest | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest |
Cie94ComparisonTest+ApplicationConstants | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s |
Cie94ComparisonTest+ApplicationConstants +ApplicationConstantsConstructor | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s+ApplicationConstantsConstructor |
Cie94ComparisonTest+Cie94ComparisonConst ructor | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Cie94ComparisonCons tructor |
Cie94ComparisonTest+Compare | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Compare |
CieDe2000ComparisonTest | Public | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest |
CieDe2000ComparisonTest+Compare | Public | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest+Compare |
CmcComparisonTest | Public | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest |
CmcComparisonTest+Compare | Public | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest+Compare |
Cie1976ComparisonTest | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest |
Cie1976ComparisonTest+Compare | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest+Compare |
Statistics
Stat | Visibility |
---|---|
Sum: | 0 |
Average: | 0 |
Minimum: | 0 |
Maximum: | 0 |
Standard deviation: | 0 |
Variance: | 0 |
![]() | Rule warning: Methods should be declared static if possible |
warnif count > 0
// When an instance method can be safely declared as static you should declare it as static.
// Since it doesn't use any instance data and method of its type and base-types,
// you should consider if such a method could be moved to a static utility class
// or if it is strongly related enough to its current declaring type to stay in it.
//
// Turning an instance method into a static method is a micro performance optimization
// since a static method is a bit cheaper to invoke than an instance method.
from t in JustMyCode.Types.Where(t =>
!t.IsStatic && !t.IsInterface &&
!t.IsEnumeration && !t.IsDelegate &&
!t.IsGeneratedByCompiler)
let methodsThatCanBeMadeStatic =
from m in t.InstanceMethods
// An instance method can be turned to static if it is not virtual,
// not using the this reference and also, not using
// any of its class or base classes instance fields or instance methods.
where !m.IsAbstract && !m.IsVirtual &&
!m.AccessThis && !m.IsExplicitInterfaceImpl &&
// Optimization: Using FirstOrDefault() avoid to check all members,
// as soon as one member is found
// we know the method m cannot be made static.
m.MembersUsed.FirstOrDefault(
mUsed => !mUsed.IsStatic &&
(mUsed.ParentType == t ||
t.DeriveFrom(mUsed.ParentType))
) == null
select m
from m in methodsThatCanBeMadeStatic
let staticFieldsUsed = m.ParentType.StaticFields.UsedBy(m).Where(f => !f.IsGeneratedByCompiler)
select new { m, staticFieldsUsed }View Code Query or Rule Body
134 methods matched
methods | staticFieldsUsed | Full Name |
---|---|---|
DegToRad(Double) | 0 field | ColorMine.ColorSpaces.Comparisons .CieDe2000Comparison.DegToRad(Double) |
ReturnsTrueForCloseNumbers() | 0 field | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo .ReturnsTrueForCloseNumbers() |
ReturnsFalseForFarNumbers() | 0 field | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo .ReturnsFalseForFarNumbers() |
ReturnsTrueForCloseNumbersWithDefaultPre cision() | 0 field | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo .ReturnsTrueForCloseNumbersWithDefaultPr ecision() |
ReturnsFalseForFarNumbersWithDefaultPrec ision() | 0 field | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo .ReturnsFalseForFarNumbersWithDefaultPre cision() |
WhiteRgbToCmy() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToCmy() |
WhiteRgbToCmyk() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToCmyk() |
WhiteRgbToHsl() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToHsl() |
WhiteRgbToHsb() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToHsb() |
WhiteRgbToLab() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToLab() |
WhiteRgbToLch() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToLch() |
WhiteRgbToRgb() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToRgb() |
WhiteRgbToXyz() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToXyz() |
WhiteRgbToYxy() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToYxy() |
WhiteRgbToLuv() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToLuv() |
WhiteRgbToHsv() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToHsv() |
WhiteRgbToHunterLab() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToHunterLab() |
BlackRgbToCmy() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToCmy() |
BlackRgbToCmyk() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToCmyk() |
BlackRgbToHsl() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToHsl() |
BlackRgbToHsb() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToHsb() |
BlackRgbToLab() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToLab() |
BlackRgbToLch() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToLch() |
BlackRgbToRgb() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToRgb() |
BlackRgbToXyz() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToXyz() |
BlackRgbToYxy() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToYxy() |
BlackRgbToLuv() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToLuv() |
BlackRgbToHsv() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToHsv() |
BlackRgbToHunterLab() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToHunterLab() |
GoldenrodRgbToCmy() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToCmy() |
GoldenrodRgbToCmyk() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToCmyk() |
GoldenrodRgbToHsl() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToHsl() |
GoldenrodRgbToHsb() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToHsb() |
GoldenrodRgbToLab() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToLab() |
GoldenrodRgbToLch() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToLch() |
GoldenrodRgbToRgb() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToRgb() |
GoldenrodRgbToXyz() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToXyz() |
GoldenrodRgbToYxy() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToYxy() |
GoldenrodRgbToLuv() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToLuv() |
GoldenrodRgbToHsv() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToHsv() |
GoldenrodRgbToHunterLab() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToHunterLab() |
SteelBlueCmyToCmy() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToCmy() |
SteelBlueCmyToCmyk() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToCmyk() |
SteelBlueCmyToHsl() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToHsl() |
SteelBlueCmyToHsb() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToHsb() |
SteelBlueCmyToLab() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToLab() |
SteelBlueCmyToLch() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToLch() |
SteelBlueCmyToRgb() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToRgb() |
SteelBlueCmyToXyz() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToXyz() |
SteelBlueCmyToYxy() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToYxy() |
SteelBlueCmyToLuv() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToLuv() |
DarkVioletCmykToCmy() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToCmy() |
DarkVioletCmykToCmyk() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToCmyk() |
DarkVioletCmykToHsl() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToHsl() |
DarkVioletCmykToHsb() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToHsb() |
DarkVioletCmykToLab() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToLab() |
DarkVioletCmykToLch() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToLch() |
DarkVioletCmykToRgb() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToRgb() |
DarkVioletCmykToXyz() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToXyz() |
DarkVioletCmykToYxy() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToYxy() |
AliceBlueHslToCmy() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToCmy() |
AliceBlueHslToCmyk() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToCmyk() |
AliceBlueHslToHsl() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToHsl() |
AliceBlueHslToHsb() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToHsb() |
AliceBlueHslToLab() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToLab() |
AliceBlueHslToLch() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToLch() |
AliceBlueHslToRgb() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToRgb() |
AliceBlueHslToXyz() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToXyz() |
AliceBlueHslToYxy() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToYxy() |
AliceBlueHsbToCmy() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToCmy() |
AliceBlueHsbToCmyk() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToCmyk() |
AliceBlueHsbToHsl() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToHsl() |
AliceBlueHsbToHsb() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToHsb() |
AliceBlueHsbToLab() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToLab() |
AliceBlueHsbToLch() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToLch() |
AliceBlueHsbToRgb() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToRgb() |
AliceBlueHsbToXyz() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToXyz() |
AliceBlueHsbToYxy() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToYxy() |
RedLabToCmy() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToCmy() |
RedLabToCmyk() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToCmyk() |
RedLabToHsl() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToHsl() |
RedLabToLab() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToLab() |
RedLabToLch() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToLch() |
RedLabToRgb() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToRgb() |
RedLabToXyz() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToXyz() |
RedLabToYxy() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToYxy() |
MaroonLchToCmy() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToCmy() |
MaroonLchToCmyk() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToCmyk() |
MaroonLchToHsl() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToHsl() |
MaroonLchToHsb() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToHsb() |
MaroonLchToLab() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToLab() |
MaroonLchToLch() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToLch() |
MaroonLchToRgb() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToRgb() |
MaroonLchToXyz() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToXyz() |
MaroonLchToYxy() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToYxy() |
RivergumXyzToCmy() | 0 field | ColorMine.Test.ColorSpaces.XyzTest+To .RivergumXyzToCmy() |
RivergumXyzToCmyk() | 0 field | ColorMine.Test.ColorSpaces.XyzTest+To .RivergumXyzToCmyk() |
RivergumXyzToHsl() | 0 field | ColorMine.Test.ColorSpaces.XyzTest+To .RivergumXyzToHsl() |
RivergumXyzToHsb() | 0 field | ColorMine.Test.ColorSpaces.XyzTest+To .RivergumXyzToHsb() |
RivergumXyzToLab() | 0 field | ColorMine.Test.ColorSpaces.XyzTest+To .RivergumXyzToLab() |
Statistics
Stat | staticFieldsUsed |
---|---|
Sum: | 0 |
Average: | 0 |
Minimum: | 0 |
Maximum: | 0 |
Standard deviation: | 0 |
Variance: | 0 |
1040
Design |
|
![]() | Rule warning: Avoid custom delegates |
// Prefer using one of the standard generic delegate type in
// Predicate<T> Func<T0,T1,..,TResult> Action<T0,T1,..>
// instead of creating your own delegate type.
// Not only the code using these custom delegates will become clearer,
// but you'll be relieved from the maintenance of these delegate types.
//
// Notice that delegate that are consumed by DllImport extern methods
// must not be converted, else this could provoke marshalling issues.
warnif count > 0
from t in Application.Types where t.IsDelegate
let invokeMethod = (from m in t.Methods where m.SimpleName == "Invoke" select m).Single()
let signature1 = invokeMethod.Name.Substring(invokeMethod.SimpleName.Length, invokeMethod.Name.Length - invokeMethod.SimpleName.Length)
// 'ref' and 'out' parameters canot be supported
where !signature1.Contains("&")
let signature2 = signature1.Replace("(","<").Replace(")",">")
let signature3 = signature2 == "<>" ? "" : signature2
let resultTypeName = invokeMethod.ReturnType == null ? "????" :
invokeMethod.ReturnType.FullName == "System.Void" ? "" :
invokeMethod.ReturnType.Name
let replaceWith = resultTypeName == "Boolean" ?
"Predicate" + signature3 : resultTypeName == "" ?
"Action" + signature3 :
"Func" + signature3.Replace(">", "," + resultTypeName + ">")
select new { t, replaceWith }View Code Query or Rule Body
1 types matched
type | replaceWith | Full Name |
---|---|---|
ComparisonAlgorithm | Func<IColorSpace,IColorSpace,Double> | ColorMine.ColorSpaces .ComparisonAlgorithm |
Statistics
Stat | replaceWith |
---|---|
Sum: | 0 |
Average: | 0 |
Minimum: | 0 |
Maximum: | 0 |
Standard deviation: | 0 |
Variance: | 0 |
![]() | Rule warning: Classes that are candidate to be turned into structures |
//
// CAUTION: Before applying this rule, make sure to understand
// the implication of transforming a class into a structure.
// http://msdn.microsoft.com/en-us/library/aa664471(v=vs.71).aspx
//
// Int32, Double or Boolean are structures and not classes.
// Structure are particularly suited to implement lightweight values.
// Hence a class is candidate to be turned into a structure
// when its instances are lightweight values.
//
warnif count > 0 from t in JustMyCode.Types where
t.IsClass &&
!t.IsGeneratedByCompiler &&
!t.IsStatic &&
t.SizeOfInst > 0 &&
t.SizeOfInst <= 16 && // Structure instance must not be too big,
// else it degrades performance.
t.NbChildren == 0 && // Must not have children
// Must not implement interfaces to avoid boxing mismatch
// when structures implements interfaces.
t.InterfacesImplemented.Count() == 0 &&
// Must have no base class
t.DepthOfDeriveFrom("System.Object".AllowNoMatch()) == 1
select new { t, t.SizeOfInst, t.InstanceFields } // Must derive directly from System.Object
// && t.IsSealed <-- You might want to add this condition
// to restraint the set.
// && t.IsImmutable <-- Structures should be immutable type.
// && t.!IsPublic <-- You might want to add this condition if
// you are developping a framework with classes
// that are intended to be sub-classed by
// your clients.
View Code Query or Rule Body
2 types matched
types | Size of instance | InstanceFields | Full Name |
---|---|---|---|
CmykProfileConverter+ProfileFilename | 12 | 3 fields | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+ProfileFilename |
CieDe2000ComparisonTest+Compare | 4 | 1 field | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest+Compare |
Statistics
Stat | Size of instance | InstanceFields |
---|---|---|
Sum: | 16 | 0 |
Average: | 8 | 0 |
Minimum: | 4 | 0 |
Maximum: | 12 | 0 |
Standard deviation: | 4 | 0 |
Variance: | 16 | 0 |
![]() | Rule warning: Avoid namespaces with few types |
warnif count > 0 from n in JustMyCode.Namespaces
let types = n.ChildTypes.Where(t => !t.IsGeneratedByCompiler)
where
types.Count() < 5
orderby types.Count() ascending
select new { n, types }
// Make sure that there is a logical organization
// to each of your namespaces, and that there is a
// valid reason for putting types in a sparsely
// populated namespace. Namespaces should contain
// types that are used together in most scenarios.
// When their applications are mutually exclusive,
// types should be located in separate namespacesView Code Query or Rule Body
2 namespaces matched
namespaces | types | Full Name |
---|---|---|
ColorMine.ColorSpaces.Conversions .Utility | 1 type | ColorMine.ColorSpaces.Conversions .Utility |
ColorMine.Test.Utility | 2 types | ColorMine.Test.Utility |
Statistics
Stat | types |
---|---|
Sum: | 0 |
Average: | 0 |
Minimum: | 0 |
Maximum: | 0 |
Standard deviation: | 0 |
Variance: | 0 |
![]() | Rule warning: Nested types should not be visible |
warnif count > 0 from t in JustMyCode.Types where
t.IsNested &&
!t.IsGeneratedByCompiler &&
!t.IsPrivate
select new { t, t.NbLinesOfCode, t.Visibility }
// A nested type is a type declared within the
// scope of another type. Nested types are useful
// for encapsulating private implementation details
// of the containing type. Used for this purpose,
// nested types should not be externally visible.
// Do not use externally visible nested types for
// logical grouping or to avoid name collisions;
// instead, use namespaces.View Code Query or Rule Body
21 types matched
types | # lines of code (LOC) | Visibility | Full Name |
---|---|---|---|
Cie94Comparison+Application | N/A | Public | ColorMine.ColorSpaces.Comparisons .Cie94Comparison+Application |
Cie94Comparison+ApplicationConstants | 10 | Internal | ColorMine.ColorSpaces.Comparisons .Cie94Comparison+ApplicationConstants |
DoubleExtensionTest+BasicallyEqualTo | 4 | Public | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo |
RgbTest+To | 108 | Public | ColorMine.Test.ColorSpaces.RgbTest+To |
CmyTest+To | 30 | Public | ColorMine.Test.ColorSpaces.CmyTest+To |
CmykTest+To | 27 | Public | ColorMine.Test.ColorSpaces.CmykTest+To |
HslTest+To | 27 | Public | ColorMine.Test.ColorSpaces.HslTest+To |
HsbTest+To | 27 | Public | ColorMine.Test.ColorSpaces.HsbTest+To |
LabTest+To | 24 | Public | ColorMine.Test.ColorSpaces.LabTest+To |
LchTest+To | 27 | Public | ColorMine.Test.ColorSpaces.LchTest+To |
XyzTest+To | 27 | Public | ColorMine.Test.ColorSpaces.XyzTest+To |
LuvTest+To | 30 | Public | ColorMine.Test.ColorSpaces.LuvTest+To |
HsvTest+To | 30 | Public | ColorMine.Test.ColorSpaces.HsvTest+To |
HunterLabTest+To | 6 | Public | ColorMine.Test.ColorSpaces .HunterLabTest+To |
Cie94ComparisonTest+ApplicationConstants | 0 | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s |
Cie94ComparisonTest+ApplicationConstants +ApplicationConstantsConstructor | 4 | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s+ApplicationConstantsConstructor |
Cie94ComparisonTest+Cie94ComparisonConst ructor | 10 | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Cie94ComparisonCons tructor |
Cie94ComparisonTest+Compare | 6 | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Compare |
CieDe2000ComparisonTest+Compare | 21 | Public | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest+Compare |
CmcComparisonTest+Compare | 15 | Public | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest+Compare |
Cie1976ComparisonTest+Compare | 15 | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest+Compare |
Statistics
Stat | # lines of code (LOC) | Visibility |
---|---|---|
Sum: | 448 | 0 |
Average: | 22.4 | 0 |
Minimum: | 0 | 0 |
Maximum: | 108 | 0 |
Standard deviation: | 22.07 | 0 |
Variance: | 487.24 | 0 |
621
Architecture and Layering |
|
![]() | Critical Rule warning: Avoid namespaces mutually dependent |
warnif count > 0
// Foreach pair of namespace mutually dependent, this rule lists pairs.
// The pair { first, second } is formatted to show first namespace shouldn't use the second namespace.
// The first/second order is inferred from the number of types used by each other.
// The first namespace is using fewer types of the second.
// It means the first namespace is certainly at a lower level in the architecture than the second.
//
// To explore the coupling between two namespaces mutually dependent:
// 1) export the first namespace to the vertical header of the dependency matrix
// 2) export the second namespace to the horizontal header of the dependency matrix
// 3) double-click the black cell
// 4) in the matrix command bar, click the button: Remove empty Row(s) en Column(s)
// At this point, the dependency matrix shows types involved into the coupling.
//
// Following this rule is useful to avoid namespaces dependency cycles.
// More on this in our white books relative to partitioning code.
// http://www.ndepend.com/WhiteBooks.aspx
// Optimization: restraint application assemblies set
// If some namespaces are mutually dependent
// - They must be declared in the same assembly
// - The parent assembly must ContainsNamespaceDependencyCycle
from assembly in Application.Assemblies.Where(a => a.ContainsNamespaceDependencyCycle != null && a.ContainsNamespaceDependencyCycle.Value)
// hashset is used to avoid reporting both A <-> B and B <-> A
let hashset = new HashSet<INamespace>()
// Optimization: restraint namespaces set
// If a namespace doesn't have a Level value, it must be in a dependency cycle
// or it must be using directly or indirectly a dependency cycle.
let namespacesSuspect = assembly.ChildNamespaces.Where(n => n.Level == null)
from nA in namespacesSuspect
// Select namespaces mutually dependent with nA
let unused = hashset.Add(nA) // Populate hashset
let namespacesMutuallyDependentWith_nA = nA.NamespacesUsed.Using(nA)
.Except(hashset) // <-- avoid reporting both A <-> B and B <-> A
where namespacesMutuallyDependentWith_nA.Count() > 0
from nB in namespacesMutuallyDependentWith_nA
// nA and nB are mutually dependent
// First select the one that shouldn't use the other.
// The first namespace is inferred from the fact that it is using less types of the second.
let typesOfBUsedByA = nB.ChildTypes.UsedBy(nA)
let typesOfAUsedByB = nA.ChildTypes.UsedBy(nB)
let first = (typesOfBUsedByA.Count() > typesOfAUsedByB.Count()) ? nB : nA
let second = (first == nA) ? nB : nA
let typesOfFirstUsedBySecond = (first == nA) ? typesOfAUsedByB : typesOfBUsedByA
let typesOfSecondUsedByFirst = (first == nA) ? typesOfBUsedByA : typesOfAUsedByB
select new { first, shouldntUse = second, typesOfFirstUsedBySecond, typesOfSecondUsedByFirst }
View Code Query or Rule Body
2 namespaces matched
namespaces | shouldntUse | typesOfFirstUsedBySecond | typesOfSecondUsedByFirst | Full Name |
---|---|---|---|---|
ColorMine.ColorSpaces | ColorMine.ColorSpaces.Comparisons | 2 types | 1 type | ColorMine.ColorSpaces |
ColorMine.ColorSpaces | ColorMine.ColorSpaces.Conversions | 20 types | 12 types | ColorMine.ColorSpaces |
Statistics
Stat | shouldntUse | typesOfFirstUsedBySecond | typesOfSecondUsedByFirst |
---|---|---|---|
Sum: | 0 | 0 | 0 |
Average: | 0 | 0 | 0 |
Minimum: | 0 | 0 | 0 |
Maximum: | 0 | 0 | 0 |
Standard deviation: | 0 | 0 | 0 |
Variance: | 0 | 0 | 0 |
![]() | Rule warning: Avoid namespaces dependency cycles |
warnif count > 0
// This query lists all application namespace dependency cycles.
// Each row shows a different cycle, prefixed with a namespace entangled in the cycle.
//
// To browse a cycle on the dependency graph or the dependency matrix, right click
// a cycle cell and export the matched namespaces to the dependency graph or matrix!
//
// In the matrix, dependency cycles are represented with red squares and black cells.
// To easily browse dependency cycles, the Matrix comes with an option:
// --> Display Direct and Indirect Dependencies
//
// Read our white books relative to partitioning code,
// to know more about namespaces dependency cycles, and why avoiding them
// is a simple but efficient solution to architecture for your code base.
// http://www.ndepend.com/WhiteBooks.aspx
// Optimization: restraint application assemblies set
// If some namespaces are mutually dependent
// - They must be declared in the same assembly
// - The parent assembly must ContainsNamespaceDependencyCycle
from assembly in Application.Assemblies
.Where(a => a.ContainsNamespaceDependencyCycle != null &&
a.ContainsNamespaceDependencyCycle.Value)
// Optimization: restraint namespaces set
// A namespace involved in a cycle necessarily have a null Level.
let namespacesSuspect = assembly.ChildNamespaces.Where(n => n.Level == null)
// hashset is used to avoid iterating again on namespaces already caught in a cycle.
let hashset = new HashSet<INamespace>()
from suspect in namespacesSuspect
// By commenting in this line, the query matches all namespaces involved in a cycle.
where !hashset.Contains(suspect)
// Define 2 code metrics
// - Namespaces depth of is using indirectly the suspect namespace.
// - Namespaces depth of is used by the suspect namespace indirectly.
// Note: for direct usage the depth is equal to 1.
let namespacesUserDepth = namespacesSuspect.DepthOfIsUsing(suspect)
let namespacesUsedDepth = namespacesSuspect.DepthOfIsUsedBy(suspect)
// Select namespaces that are both using and used by namespaceSuspect
let usersAndUsed = from n in namespacesSuspect where
namespacesUserDepth[n] > 0 &&
namespacesUsedDepth[n] > 0
select n
where usersAndUsed.Count() > 0
// Here we've found namespace(s) both using and used by the suspect namespace.
// A cycle involving the suspect namespace is found!
let cycle = usersAndUsed.Append(suspect)
// Fill hashset with namespaces in the cycle.
// .ToArray() is needed to force the iterating process.
let unused1 = (from n in cycle let unused2 = hashset.Add(n) select n).ToArray()
select new { suspect, cycle }
View Code Query or Rule Body
1 namespaces matched
namespace | cycle | Full Name |
---|---|---|
ColorMine.ColorSpaces | 3 namespaces | ColorMine.ColorSpaces |
Statistics
Stat | cycle |
---|---|
Sum: | 0 |
Average: | 0 |
Minimum: | 0 |
Maximum: | 0 |
Standard deviation: | 0 |
Variance: | 0 |
![]() | Rule warning: Assemblies with poor cohesion (RelationalCohesion) |
warnif count > 0 from a in Application.Assemblies where
a.NbTypes > 20 && // Relational Cohesion metrics is relevant only if there are several types
(a.RelationalCohesion < 1.5 ||
a.RelationalCohesion > 4.0)
select new { a, a.NbTypes, a.RelationalCohesion }
// As classes inside an assembly should be strongly related,
// the cohesion should be high. On the other hand, a value
// which is too high may indicate over-coupling. A good range
// for RelationalCohesion is 1.5 to 4.0.
// See the definition of the RelationalCohesion metric here
// http://www.ndepend.com/Metrics.aspx#RelationalCohesionView Code Query or Rule Body
1 assemblies matched
assembly | # Types | Relational cohesion | Full Name |
---|---|---|---|
ColorMine.Test | 36 | 0.89 | ColorMine.Test |
Statistics
Stat | # Types | Relational cohesion |
---|---|---|
Sum: | 36 | 0.89 |
Average: | 36 | 0.89 |
Minimum: | 36 | 0.89 |
Maximum: | 36 | 0.89 |
Standard deviation: | 0 | 0 |
Variance: | 0 | 0 |
202
Dead Code |
|
![]() | Critical Rule warning: Potentially dead Methods |
warnif count > 0
// Filter procedure for methods that should'nt be considered as dead
let canMethodBeConsideredAsDeadProc = new Func<IMethod, bool>(
m => !m.IsPubliclyVisible && // Public methods might be used by client applications of your assemblies.
!m.IsEntryPoint && // Main() method is not used by-design.
!m.IsExplicitInterfaceImpl && // The IL code never explicitely calls explicit interface methods implementation.
!m.IsClassConstructor && // The IL code never explicitely calls class constructors.
!m.IsFinalizer && // The IL code never explicitely calls finalizers.
!m.IsVirtual && // Only check for non virtual method that are not seen as used in IL.
!(m.IsConstructor && // Don't take account of protected ctor that might be call by a derived ctors.
m.IsProtected) &&
!m.IsEventAdder && // The IL code never explicitely calls events adder/remover.
!m.IsEventRemover &&
!m.IsGeneratedByCompiler &&
!m.ParentType.IsDelegate &&
// Methods tagged with these two attributes are called by the serialization infrastructure.
!m.HasAttribute("System.Runtime.Serialization.OnSerializingAttribute".AllowNoMatch()) &&
!m.HasAttribute("System.Runtime.Serialization.OnDeserializedAttribute".AllowNoMatch()) &&
// If you don't want to link NDepend.API.dll, you can use your own IsNotDeadCodeAttribute and adapt this rule.
!m.HasAttribute("NDepend.Attributes.IsNotDeadCodeAttribute".AllowNoMatch()))
// Get methods unused
let methodsUnused =
from m in JustMyCode.Methods where
m.NbMethodsCallingMe == 0 &&
canMethodBeConsideredAsDeadProc(m)
select m
// Dead methods = methods used only by unused methods (recursive)
let deadMethodsMetric = methodsUnused.FillIterative(
methods => // Unique loop, just to let a chance to build the hashset.
from o in (new object()).ToEnumerable()
// Use a hashet to make Intersect calls much faster!
let hashset = methods.ToHashSet()
from m in codeBase.Application.Methods.UsedByAny(methods).Except(methods)
where canMethodBeConsideredAsDeadProc(m) &&
// Select methods called only by methods already considered as dead
hashset.Intersect(m.MethodsCallingMe).Count() == m.NbMethodsCallingMe
select m)
from m in JustMyCode.Methods.Intersect(deadMethodsMetric.DefinitionDomain)
select new { m, m.MethodsCallingMe, depth = deadMethodsMetric[m] }View Code Query or Rule Body
1 methods matched
method | MethodsCallingMe | depth | Full Name |
---|---|---|---|
.ctor() | 0 method | 0 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter..ctor() |
Statistics
Stat | MethodsCallingMe | depth |
---|---|---|
Sum: | 0 | 0 |
Average: | 0 | 0 |
Minimum: | 0 | 0 |
Maximum: | 0 | 0 |
Standard deviation: | 0 | 0 |
Variance: | 0 | 0 |
![]() | Critical Rule warning: Potentially dead Fields |
warnif count > 0
from f in JustMyCode.Fields where
f.NbMethodsUsingMe == 0 &&
!f.IsPublic && // Although not recommended, public fields might be used by client applications of your assemblies.
!f.IsLiteral && // The IL code never explicitely uses literal fields.
!f.IsEnumValue && // The IL code never explicitely uses enumeration value.
f.Name != "value__" && // Field named 'value__' are relative to enumerations and the IL code never explicitely uses them.
!f.HasAttribute("NDepend.Attributes.IsNotDeadCodeAttribute".AllowNoMatch()) &&
!f.IsGeneratedByCompiler
// If you don't want to link NDepend.API.dll, you can use your own IsNotDeadCodeAttribute and adapt this rule.
select fView Code Query or Rule Body
1 fields matched
field | Full Name |
---|---|
pad | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor.pad |
Statistics
Stat |
---|
Sum: |
Average: |
Minimum: |
Maximum: |
Standard deviation: |
Variance: |
470
Visibility |
|
![]() | Rule warning: Methods that could have a lower visibility |
warnif count > 0 from m in JustMyCode.Methods where
m.Visibility != m.OptimalVisibility &&
!m.HasAttribute("NDepend.Attributes.CannotDecreaseVisibilityAttribute".AllowNoMatch()) &&
!m.HasAttribute("NDepend.Attributes.IsNotDeadCodeAttribute".AllowNoMatch()) &&
// If you don't want to link NDepend.API.dll, you can use your own attributes and adapt this rule.
// Eliminate default constructor from the result.
// Whatever the visibility of the declaring class,
// default constructors are public and introduce noise
// in the current rule.
!( m.IsConstructor && m.IsPublic && m.NbParameters == 0) &&
// Don't decrease the visibility of Main() methods.
!m.IsEntryPoint
select new { m,
m.Visibility ,
CouldBeDeclared = m.OptimalVisibility,
m.MethodsCallingMe }View Code Query or Rule Body
146 methods matched
methods | Visibility | CouldBeDeclared | MethodsCallingMe | Full Name |
---|---|---|---|---|
WithProfile(IColorSpace,Uri) | Public | Private | 0 method | ColorMine.ColorSpaces .ColorSpaceExtensions.WithProfile (IColorSpace,Uri) |
To<T>(IColorSpaceWithProfile) | Public | Private | 0 method | ColorMine.ColorSpaces .ColorSpaceExtensions.To<T> (IColorSpaceWithProfile) |
ToColorSpace(IRgb,ICmyk) | Public | Internal | 2 methods | ColorMine.ColorSpaces.Conversions .CmykConverter.ToColorSpace(IRgb,ICmyk) |
ToColorSpace(IRgb,ICmyk,Uri) | Public | Internal | 2 methods | ColorMine.ColorSpaces.Conversions .CmykConverter.ToColorSpace(IRgb,ICmyk ,Uri) |
ToColorSpace(IRgb,ICmyk,Uri,Uri) | Public | Private | 0 method | ColorMine.ColorSpaces.Conversions .CmykConverter.ToColorSpace(IRgb,ICmyk ,Uri,Uri) |
ToColor(ICmyk) | Public | Internal | 1 method | ColorMine.ColorSpaces.Conversions .CmykConverter.ToColor(ICmyk) |
ToColor(ICmyk,Uri) | Public | Internal | 1 method | ColorMine.ColorSpaces.Conversions .CmykConverter.ToColor(ICmyk,Uri) |
ReturnsTrueForCloseNumbers() | Public | Private | 0 method | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo .ReturnsTrueForCloseNumbers() |
ReturnsFalseForFarNumbers() | Public | Private | 0 method | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo .ReturnsFalseForFarNumbers() |
ReturnsTrueForCloseNumbersWithDefaultPre cision() | Public | Private | 0 method | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo .ReturnsTrueForCloseNumbersWithDefaultPr ecision() |
ReturnsFalseForFarNumbersWithDefaultPrec ision() | Public | Private | 0 method | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo .ReturnsFalseForFarNumbersWithDefaultPre cision() |
WhiteRgbToCmy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToCmy() |
WhiteRgbToCmyk() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToCmyk() |
WhiteRgbToHsl() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToHsl() |
WhiteRgbToHsb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToHsb() |
WhiteRgbToLab() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToLab() |
WhiteRgbToLch() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToLch() |
WhiteRgbToRgb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToRgb() |
WhiteRgbToXyz() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToXyz() |
WhiteRgbToYxy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToYxy() |
WhiteRgbToLuv() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToLuv() |
WhiteRgbToHsv() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToHsv() |
WhiteRgbToHunterLab() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToHunterLab() |
BlackRgbToCmy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToCmy() |
BlackRgbToCmyk() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToCmyk() |
BlackRgbToHsl() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToHsl() |
BlackRgbToHsb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToHsb() |
BlackRgbToLab() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToLab() |
BlackRgbToLch() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToLch() |
BlackRgbToRgb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToRgb() |
BlackRgbToXyz() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToXyz() |
BlackRgbToYxy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToYxy() |
BlackRgbToLuv() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToLuv() |
BlackRgbToHsv() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToHsv() |
BlackRgbToHunterLab() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToHunterLab() |
GoldenrodRgbToCmy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToCmy() |
GoldenrodRgbToCmyk() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToCmyk() |
GoldenrodRgbToHsl() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToHsl() |
GoldenrodRgbToHsb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToHsb() |
GoldenrodRgbToLab() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToLab() |
GoldenrodRgbToLch() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToLch() |
GoldenrodRgbToRgb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToRgb() |
GoldenrodRgbToXyz() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToXyz() |
GoldenrodRgbToYxy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToYxy() |
GoldenrodRgbToLuv() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToLuv() |
GoldenrodRgbToHsv() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToHsv() |
GoldenrodRgbToHunterLab() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToHunterLab() |
SteelBlueCmyToCmy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToCmy() |
SteelBlueCmyToCmyk() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToCmyk() |
SteelBlueCmyToHsl() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToHsl() |
SteelBlueCmyToHsb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToHsb() |
SteelBlueCmyToLab() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToLab() |
SteelBlueCmyToLch() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToLch() |
SteelBlueCmyToRgb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToRgb() |
SteelBlueCmyToXyz() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToXyz() |
SteelBlueCmyToYxy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToYxy() |
SteelBlueCmyToLuv() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToLuv() |
DarkVioletCmykToCmy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToCmy() |
DarkVioletCmykToCmyk() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToCmyk() |
DarkVioletCmykToHsl() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToHsl() |
DarkVioletCmykToHsb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToHsb() |
DarkVioletCmykToLab() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToLab() |
DarkVioletCmykToLch() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToLch() |
DarkVioletCmykToRgb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToRgb() |
DarkVioletCmykToXyz() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToXyz() |
DarkVioletCmykToYxy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToYxy() |
AliceBlueHslToCmy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToCmy() |
AliceBlueHslToCmyk() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToCmyk() |
AliceBlueHslToHsl() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToHsl() |
AliceBlueHslToHsb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToHsb() |
AliceBlueHslToLab() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToLab() |
AliceBlueHslToLch() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToLch() |
AliceBlueHslToRgb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToRgb() |
AliceBlueHslToXyz() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToXyz() |
AliceBlueHslToYxy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToYxy() |
AliceBlueHsbToCmy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToCmy() |
AliceBlueHsbToCmyk() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToCmyk() |
AliceBlueHsbToHsl() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToHsl() |
AliceBlueHsbToHsb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToHsb() |
AliceBlueHsbToLab() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToLab() |
AliceBlueHsbToLch() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToLch() |
AliceBlueHsbToRgb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToRgb() |
AliceBlueHsbToXyz() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToXyz() |
AliceBlueHsbToYxy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToYxy() |
RedLabToCmy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToCmy() |
RedLabToCmyk() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToCmyk() |
RedLabToHsl() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToHsl() |
RedLabToLab() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToLab() |
RedLabToLch() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToLch() |
RedLabToRgb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToRgb() |
RedLabToXyz() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToXyz() |
RedLabToYxy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToYxy() |
MaroonLchToCmy() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToCmy() |
MaroonLchToCmyk() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToCmyk() |
MaroonLchToHsl() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToHsl() |
MaroonLchToHsb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToHsb() |
MaroonLchToLab() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToLab() |
MaroonLchToLch() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToLch() |
MaroonLchToRgb() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToRgb() |
MaroonLchToXyz() | Public | Private | 0 method | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToXyz() |
Statistics
Stat | Visibility | CouldBeDeclared | MethodsCallingMe |
---|---|---|---|
Sum: | 0 | 0 | 0 |
Average: | 0 | 0 | 0 |
Minimum: | 0 | 0 | 0 |
Maximum: | 0 | 0 | 0 |
Standard deviation: | 0 | 0 | 0 |
Variance: | 0 | 0 | 0 |
![]() | Rule warning: Types that could have a lower visibility |
warnif count > 0 from t in JustMyCode.Types where
t.Visibility != t.OptimalVisibility &&
// If you don't want to link NDepend.API.dll, you can use your own attributes and adapt this rule.
!t.HasAttribute("NDepend.Attributes.CannotDecreaseVisibilityAttribute".AllowNoMatch()) &&
!t.HasAttribute("NDepend.Attributes.IsNotDeadCodeAttribute".AllowNoMatch()) &&
// Static types that define only const fields cannot be seen as used in IL code.
// They don't have to be tagged with CannotDecreaseVisibilityAttribute.
!( t.IsStatic &&
!t.Methods.Any(m => !m.IsClassConstructor) &&
!t.Fields.Any(f => !f.IsLiteral && !(f.IsStatic && f.IsInitOnly))) &&
// A type used by an interface that has the same visibility
// cannot have its visibility decreased, else a compilation error occurs!
!t.TypesUsingMe.Any(tUser =>
tUser.IsInterface &&
tUser.Visibility == t.Visibility)
select new { t, t.Visibility ,
CouldBeDeclared = t.OptimalVisibility,
t.TypesUsingMe }
View Code Query or Rule Body
39 types matched
types | Visibility | CouldBeDeclared | TypesUsingMe | Full Name |
---|---|---|---|---|
IColorSpaceWithProfile | Public | Internal | 2 types | ColorMine.ColorSpaces .IColorSpaceWithProfile |
ColorSpaceWithProfile | Public | Internal | 1 type | ColorMine.ColorSpaces .ColorSpaceWithProfile |
ColorSpaceExtensions | Public | Internal | 0 type | ColorMine.ColorSpaces .ColorSpaceExtensions |
CmykConverter | Public | Internal | 2 types | ColorMine.ColorSpaces.Conversions .CmykConverter |
DoubleExtensionTest | Public | Internal | 0 type | ColorMine.Test.Utility .DoubleExtensionTest |
DoubleExtensionTest+BasicallyEqualTo | Public | Private | 1 type | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo |
RgbTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.RgbTest |
RgbTest+To | Public | Private | 1 type | ColorMine.Test.ColorSpaces.RgbTest+To |
CmyTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.CmyTest |
CmyTest+To | Public | Private | 1 type | ColorMine.Test.ColorSpaces.CmyTest+To |
CmykTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.CmykTest |
CmykTest+To | Public | Private | 1 type | ColorMine.Test.ColorSpaces.CmykTest+To |
HslTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.HslTest |
HslTest+To | Public | Private | 1 type | ColorMine.Test.ColorSpaces.HslTest+To |
HsbTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.HsbTest |
HsbTest+To | Public | Private | 1 type | ColorMine.Test.ColorSpaces.HsbTest+To |
LabTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.LabTest |
LabTest+To | Public | Private | 1 type | ColorMine.Test.ColorSpaces.LabTest+To |
LchTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.LchTest |
LchTest+To | Public | Private | 1 type | ColorMine.Test.ColorSpaces.LchTest+To |
XyzTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.XyzTest |
XyzTest+To | Public | Private | 1 type | ColorMine.Test.ColorSpaces.XyzTest+To |
LuvTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.LuvTest |
LuvTest+To | Public | Private | 1 type | ColorMine.Test.ColorSpaces.LuvTest+To |
HsvTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.HsvTest |
HsvTest+To | Public | Private | 1 type | ColorMine.Test.ColorSpaces.HsvTest+To |
HunterLabTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.HunterLabTest |
HunterLabTest+To | Public | Private | 1 type | ColorMine.Test.ColorSpaces .HunterLabTest+To |
Cie94ComparisonTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest |
Cie94ComparisonTest+ApplicationConstants | Public | Private | 1 type | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s |
Cie94ComparisonTest+ApplicationConstants +ApplicationConstantsConstructor | Public | Internal | 2 types | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s+ApplicationConstantsConstructor |
Cie94ComparisonTest+Cie94ComparisonConst ructor | Public | Private | 1 type | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Cie94ComparisonCons tructor |
Cie94ComparisonTest+Compare | Public | Private | 1 type | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Compare |
CieDe2000ComparisonTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest |
CieDe2000ComparisonTest+Compare | Public | Private | 1 type | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest+Compare |
CmcComparisonTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest |
CmcComparisonTest+Compare | Public | Private | 1 type | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest+Compare |
Cie1976ComparisonTest | Public | Internal | 0 type | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest |
Cie1976ComparisonTest+Compare | Public | Private | 1 type | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest+Compare |
Statistics
Stat | Visibility | CouldBeDeclared | TypesUsingMe |
---|---|---|---|
Sum: | 0 | 0 | 0 |
Average: | 0 | 0 | 0 |
Minimum: | 0 | 0 | 0 |
Maximum: | 0 | 0 | 0 |
Standard deviation: | 0 | 0 | 0 |
Variance: | 0 | 0 | 0 |
![]() | Rule warning: Fields that could have a lower visibility |
warnif count > 0 from f in JustMyCode.Fields where
f.Visibility != f.OptimalVisibility &&
!f.HasAttribute("NDepend.Attributes.CannotDecreaseVisibilityAttribute".AllowNoMatch()) &&
!f.HasAttribute("NDepend.Attributes.IsNotDeadCodeAttribute".AllowNoMatch())
// If you don't want to link NDepend.API.dll, you can use your own attributes and adapt this rule.
select new { f,
f.Visibility ,
CouldBeDeclared = f.OptimalVisibility,
f.MethodsUsingMe }View Code Query or Rule Body
2 fields matched
fields | Visibility | CouldBeDeclared | MethodsUsingMe | Full Name |
---|---|---|---|---|
type | Internal | Private | 1 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+ProfileFilename .type |
pad | Internal | Private | 0 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor.pad |
Statistics
Stat | Visibility | CouldBeDeclared | MethodsUsingMe |
---|---|---|---|
Sum: | 0 | 0 | 0 |
Average: | 0 | 0 | 0 |
Minimum: | 0 | 0 | 0 |
Maximum: | 0 | 0 | 0 |
Standard deviation: | 0 | 0 | 0 |
Variance: | 0 | 0 | 0 |
![]() | Rule warning: Types that could be declared as private, nested in a parent type |
// The conditions for a type to be nested into a parent type
// is that the parent type is the only type using it,
// and that the parent type is declared in the same namespace.
//
// Declaring a type as private into a parent type helps enforcing encapsulation.
// But since nested private types are hardly testable, this rule might
// not be applied for types used directly by tests.
warnif count > 0
from t in Application.Types
where !t.IsGeneratedByCompiler &&
!t.IsNested &&
!t.IsPubliclyVisible &&
// Only one type user...
t.TypesUsingMe.Count() == 1
let couldBeNestedIn = t.TypesUsingMe.Single()
where !couldBeNestedIn.IsGeneratedByCompiler &&
// ...declared in the same namespace
couldBeNestedIn.ParentNamespace == t.ParentNamespace
select new { t, couldBeNestedIn }View Code Query or Rule Body
1 types matched
type | couldBeNestedIn | Full Name |
---|---|---|
CmykProfileConverter | CmykConverter | ColorMine.ColorSpaces.Conversions .CmykProfileConverter |
Statistics
Stat | couldBeNestedIn |
---|---|
Sum: | 0 |
Average: | 0 |
Minimum: | 0 |
Maximum: | 0 |
Standard deviation: | 0 |
Variance: | 0 |
![]() | Rule warning: Avoid publicly visible constant fields |
// Match constant fields which are visible outside their parent assembly.
// Such field, when used outside its parent assembly,
// has its constant value hard-coded into the client assembly.
// Changing the field's value requires to recompile all assemblies
// that use the field.
// Declare the field as static readonly instead. This way, the value can be
// safely changed, without the need to recompile client assemblies.
warnif count > 0
from f in Application.Fields
where f.IsLiteral && f.IsPubliclyVisible
&& !f.IsEnumValue // This situation also applies to enumeration values
// but to avoid too many false positives, per default
// this rule doesn't match these particular fields.
select fView Code Query or Rule Body
2 fields matched
fields | Full Name |
---|---|
DefaultLightness | ColorMine.ColorSpaces.Comparisons .CmcComparison.DefaultLightness |
DefaultChroma | ColorMine.ColorSpaces.Comparisons .CmcComparison.DefaultChroma |
Statistics
Stat |
---|
Sum: |
Average: |
Minimum: |
Maximum: |
Standard deviation: |
Variance: |
![]() | Rule warning: Fields should be declared as private |
// Fields should be considered as implementation details
// and as a consequence they should be declared as private.
// When a field is private, the caller cannot get
// inappropriate direct access to the field.
warnif count > 0 from f in Application.Fields where
!f.IsPrivate &&
// These conditions filter cases where fields
// doesn't represent state that should be encapsulated.
!f.IsGeneratedByCompiler &&
!f.IsSpecialName &&
!f.IsInitOnly &&
!f.IsLiteral &&
!f.IsEnumValue
// A non-private field assigned from outside its class,
// usually leads to complicated field state management.
let outsideMethodsAssigningMe =
f.MethodsAssigningMe.Where(m => m.ParentType != f.ParentType)
select new { f,
f.Visibility,
outsideMethodsAssigningMe }View Code Query or Rule Body
10 fields matched
fields | Visibility | outsideMethodsAssigningMe | Full Name |
---|---|---|---|
cyan | Internal | 0 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+CmykColor.cyan |
magenta | Internal | 0 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+CmykColor.magenta |
yellow | Internal | 0 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+CmykColor.yellow |
black | Internal | 0 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+CmykColor.black |
type | Internal | 0 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+ProfileFilename .type |
profileData | Internal | 0 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+ProfileFilename .profileData |
red | Internal | 1 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor.red |
green | Internal | 1 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor.green |
blue | Internal | 1 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor.blue |
pad | Internal | 0 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor.pad |
Statistics
Stat | Visibility | outsideMethodsAssigningMe |
---|---|---|
Sum: | 0 | 0 |
Average: | 0 | 0 |
Minimum: | 0 | 0 |
Maximum: | 0 | 0 |
Standard deviation: | 0 | 0 |
Variance: | 0 | 0 |
![]() | Rule warning: Avoid public methods not publicly visible |
// Matched methods are declared public but are not publicly visible by assemblies consumers.
// Their visibility level must be decreased.
warnif count > 0
from m in JustMyCode.Methods where
!m.IsPubliclyVisible && m.IsPublic &&
// Eliminate virtual methods
!m.IsVirtual &&
// Eliminate interface and delegate types
!m.ParentType.IsInterface &&
!m.ParentType.IsDelegate &&
// Eliminate default constructors
!(m.IsConstructor && m.NbParameters == 0) &&
// Eliminate operators that must be declared public
!m.IsOperator &&
// Eliminate methods generated by compiler
!m.IsGeneratedByCompiler
select mView Code Query or Rule Body
1 methods matched
method | Full Name |
---|---|
.ctor(Cie94Comparison+Application) | ColorMine.ColorSpaces.Comparisons .Cie94Comparison+ApplicationConstants. .ctor(Cie94Comparison+Application) |
Statistics
Stat |
---|
Sum: |
Average: |
Minimum: |
Maximum: |
Standard deviation: |
Variance: |
830
Purity - Immutability - Side-Effects |
|
![]() | Rule warning: Fields should be marked as ReadOnly when possible |
warnif count > 0
from f in JustMyCode.Fields where
f.IsImmutable &&
!f.IsInitOnly &&
!f.IsGeneratedByCompiler &&
!f.IsEventDelegateObject
select new { f, f.SizeOfInst }
// A field that matches the condition IsImmutable
// is a field that is assigned only by constructors
// of its class.
// For an instance field, this means its value
// will remain constant throught the lifetime
// of the object.
// For a static field, this means its value will
// remain constant throught the lifetime of the
// program.
// In both cases, such field can safely be marked
// with the C# readonly keyword
// (ReadOnly in VB.NET).
// The condition IsInitOnly matches fields that
// are marked with the C# readonly keyword
// (ReadOnly in VB.NET).
View Code Query or Rule Body
1 fields matched
field | Size of instance | Full Name |
---|---|---|
dataSize | 4 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+ProfileFilename .dataSize |
Statistics
Stat | Size of instance |
---|---|
Sum: | 4 |
Average: | 4 |
Minimum: | 4 |
Maximum: | 4 |
Standard deviation: | 0 |
Variance: | 0 |
![]() | Rule warning: Structures should be immutable |
warnif count > 0 from t in Application.Types where
t.IsStructure &&
!t.IsImmutable
let mutableFields = t.Fields.Where(f => !f.IsImmutable)
select new { t, t.NbLinesOfCode, mutableFields }
// It is deemed as a good practice to make
// your structure immutable.
// An object is immutable if its state doesn’t
// change once the object has been created.
// Consequently, a structure is immutable if
// its instances are immutable.
// Immutable types naturally simplify code by
// limiting side-effects.
// See some explanations on immutability and
// how NDepend supports it here:
// http://codebetter.com/blogs/patricksmacchia/archive/2008/01/13/immutable-types-understand-them-and-use-them.aspx
View Code Query or Rule Body
2 types matched
types | # lines of code (LOC) | mutableFields | Full Name |
---|---|---|---|
CmykProfileConverter+CmykColor | 0 | 4 fields | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+CmykColor |
CmykProfileConverter+RgbColor | 0 | 4 fields | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor |
Statistics
Stat | # lines of code (LOC) | mutableFields |
---|---|---|
Sum: | 0 | 0 |
Average: | 0 | 0 |
Minimum: | 0 | 0 |
Maximum: | 0 | 0 |
Standard deviation: | 0 | 0 |
Variance: | 0 | 0 |
![]() | Rule warning: A field must not be assigned from outside its parent hierarchy types |
warnif count > 0
from f in JustMyCode.Fields.Where(f =>
!f.IsPrivate && !f.IsGeneratedByCompiler &&
!f.IsImmutable && !f.IsEnumValue)
let methodsAssignerOutsideOfMyType = f.MethodsAssigningMe.Where(
m =>!m.IsGeneratedByCompiler &&
m.ParentType != f.ParentType &&
!m.ParentType.DeriveFrom(f.ParentType) )
where methodsAssignerOutsideOfMyType.Count() > 0
select new { f, methodsAssignerOutsideOfMyType }View Code Query or Rule Body
3 fields matched
fields | methodsAssignerOutsideOfMyType | Full Name |
---|---|---|
red | 1 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor.red |
green | 1 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor.green |
blue | 1 method | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor.blue |
Statistics
Stat | methodsAssignerOutsideOfMyType |
---|---|
Sum: | 0 |
Average: | 0 |
Minimum: | 0 |
Maximum: | 0 |
Standard deviation: | 0 |
Variance: | 0 |
1430
Naming Conventions |
|
![]() | Rule warning: Instance fields should be prefixed with a 'm_' |
warnif count > 0 from f in Application.Fields where
!f.NameLike (@"^m_") &&
!f.IsStatic &&
!f.IsLiteral &&
!f.IsGeneratedByCompiler &&
!f.IsSpecialName &&
!f.IsEventDelegateObject
select new { f, f.SizeOfInst }
// This naming convention provokes debate.
// Don't hesitate to customize the regex of
// NameLike to your preference.View Code Query or Rule Body
13 fields matched
fields | Size of instance | Full Name |
---|---|---|
_lightness | 8 | ColorMine.ColorSpaces.Comparisons .CmcComparison._lightness |
_chroma | 8 | ColorMine.ColorSpaces.Comparisons .CmcComparison._chroma |
cyan | 2 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+CmykColor.cyan |
magenta | 2 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+CmykColor.magenta |
yellow | 2 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+CmykColor.yellow |
black | 2 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+CmykColor.black |
type | 4 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+ProfileFilename .type |
profileData | 4 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+ProfileFilename .profileData |
dataSize | 4 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+ProfileFilename .dataSize |
red | 2 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor.red |
green | 2 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor.green |
blue | 2 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor.blue |
pad | 2 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor.pad |
Statistics
Stat | Size of instance |
---|---|
Sum: | 44 |
Average: | 3.38 |
Minimum: | 2 |
Maximum: | 8 |
Standard deviation: | 2.13 |
Variance: | 4.54 |
![]() | Rule warning: Abstract base class should be suffixed with 'Base' |
warnif count > 0 from t in Application.Types where
t.IsAbstract &&
t.IsClass &&
// equivalent to: DepthOfDeriveFrom "System.Object" == 1
t.DepthOfInheritance == 1 &&
((!t.IsGeneric && !t.NameLike (@"Base$")) ||
( t.IsGeneric && !t.NameLike (@"Base<")))
select new { t, t.DepthOfInheritance }View Code Query or Rule Body
2 types matched
types | Depth of inheritance | Full Name |
---|---|---|
ColorSpace | 1 | ColorMine.ColorSpaces.ColorSpace |
ColorSpaceTest | 1 | ColorMine.Test.ColorSpaces .ColorSpaceTest |
Statistics
Stat | Depth of inheritance |
---|---|
Sum: | 2 |
Average: | 1 |
Minimum: | 1 |
Maximum: | 1 |
Standard deviation: | 0 |
Variance: | 0 |
![]() | Rule warning: Avoid methods with name too long |
warnif count > 0 from m in Application.Methods where
!m.IsExplicitInterfaceImpl &&
!m.IsGeneratedByCompiler &&
((!m.IsSpecialName && m.SimpleName.Length > 35) ||
// Property getter/setter are prefixed with "get_" "set_" of length 4.
( m.IsSpecialName && m.SimpleName.Length - 4 > 35))
select new { m, m.SimpleName }
// The regex matches methods with name longer
// than 35 characters.
// Method Name doesn't contain the type and namespace
// prefix, FullName does.
// The regex computes the method name length from
// the beginning until the first open parenthesis
// or first lower than (for generic methods).
// Explicit Interface Implementation methods are
// discarded because their names are prefixed
// with the interface name.
View Code Query or Rule Body
6 methods matched
methods | SimpleName | Full Name |
---|---|---|
ReturnsTrueForCloseNumbersWithDefaultPre cision() | ReturnsTrueForCloseNumbersWithDefaultPrecision | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo .ReturnsTrueForCloseNumbersWithDefaultPr ecision() |
ReturnsFalseForFarNumbersWithDefaultPrec ision() | ReturnsFalseForFarNumbersWithDefaultPrecision | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo .ReturnsFalseForFarNumbersWithDefaultPre cision() |
ReturnsKnownValueForGraphicArtsPinks() | ReturnsKnownValueForGraphicArtsPinks | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Compare .ReturnsKnownValueForGraphicArtsPinks() |
ReturnsKnownValueForWhiteAndEggShell2() | ReturnsKnownValueForWhiteAndEggShell2 | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest+Compare .ReturnsKnownValueForWhiteAndEggShell2() |
ReturnsKnownValueForWhiteAndEggShell1() | ReturnsKnownValueForWhiteAndEggShell1 | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest+Compare .ReturnsKnownValueForWhiteAndEggShell1() |
ReturnsKnownValueForDissimilarColors() | ReturnsKnownValueForDissimilarColors | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest+Compare .ReturnsKnownValueForDissimilarColors() |
Statistics
Stat | SimpleName |
---|---|
Sum: | 0 |
Average: | 0 |
Minimum: | 0 |
Maximum: | 0 |
Standard deviation: | 0 |
Variance: | 0 |
510
Source Files Organization |
|
![]() | Rule warning: Avoid defining multiple types in a source file |
warnif count > 0
// Build a lookup indexed by source files, values being a sequence of types defined in the source file.
let lookup = Application.Types.Where(t =>
t.SourceFileDeclAvailable &&
// except nested types and types generated by compilers!
!t.IsGeneratedByCompiler &&
!t.IsNested)
// It could make sense to not apply this rule for enumerations.
// && !t.IsEnumeration)
// We use multi-key, since a type can be declared in multiple source files.
.ToMultiKeyLookup(t => t.SourceDecls.Select(d => d.SourceFile))
from @group in lookup where @group.Count() > 1
let sourceFile = @group.Key
// CQLinq doesn't let indexing result with sourceFile
// so we choose a typeIndex in types,
// preferably the type that has the file name.
let typeWithSourceFileName = @group.FirstOrDefault(t => t.SimpleName == sourceFile.FileNameWithoutExtension)
let typeIndex = typeWithSourceFileName ?? @group.First()
select new { typeIndex,
types = @group as IEnumerable<IType>,
sourceFile.FilePathString }View Code Query or Rule Body
3 types matched
types | types | FilePathString | Full Name |
---|---|---|---|
ColorSpace | 2 types | \\psf\dropbox\projects\ColorMine\ColorMine\ColorSpaces\ColorSpace.cs | ColorMine.ColorSpaces.ColorSpace |
IRgb | 24 types | \\psf\dropbox\projects\ColorMine\ColorMine\ColorSpaces\ColorSpaces.cs | ColorMine.ColorSpaces.IRgb |
ColorSpaceWithProfile | 3 types | \\psf\dropbox\projects\ColorMine\ColorMine\ColorSpaces\ColorSpaceWithProfile.cs | ColorMine.ColorSpaces .ColorSpaceWithProfile |
Statistics
Stat | types | FilePathString |
---|---|---|
Sum: | 0 | 0 |
Average: | 0 | 0 |
Minimum: | 0 | 0 |
Maximum: | 0 | 0 |
Standard deviation: | 0 | 0 |
Variance: | 0 | 0 |
2940
.NET Framework Usage |
|
1120
System |
|
![]() | Rule warning: Mark assemblies with CLSCompliant |
warnif count > 0 from a in Application.Assemblies where
!a.HasAttribute ("System.CLSCompliantAttribute".AllowNoMatch())
select a
// The Common Language Specification (CLS) defines
// naming restrictions, data types, and rules to which
// assemblies must conform if they are to be used
// across programming languages. Good design dictates
// that all assemblies explicitly indicate CLS
// compliance with CLSCompliantAttribute. If the
// attribute is not present on an assembly, the
// assembly is not compliant.View Code Query or Rule Body
2 assemblies matched
assemblies | Full Name |
---|---|
ColorMine | ColorMine |
ColorMine.Test | ColorMine.Test |
Statistics
Stat |
---|
Sum: |
Average: |
Minimum: |
Maximum: |
Standard deviation: |
Variance: |
![]() | Rule warning: Enum Storage should be Int32 |
warnif count > 0 from f in Fields where
f.Name == @"value__" &&
!f.FieldTypeIs ("System.Int32".AllowNoMatch()) &&
!f.IsThirdParty
select new { f, f.SizeOfInst, f.FieldType }
// An enumeration is a value type that defines
// a set of related named constants. By default,
// the System.Int32 data type is used to store
// the constant value. Even though you can change
// this underlying type, it is not necessary or
// recommended for most scenarios. Note that there
// is no significant performance gain in using
// a data type smaller than Int32. If you cannot
// use the default data type, you should use one
// of the CLS-compliant integral types, Byte,
// Int16, Int32, or Int64, to ensure that all of
// the enumeration's values are representable in
// CLS-compliant programming languages.View Code Query or Rule Body
4 fields matched
fields | Size of instance | FieldType | Full Name |
---|---|---|---|
value__ | 4 | UInt32 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+ColorTransformMode .value__ |
value__ | 4 | UInt32 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+CreateDisposition .value__ |
value__ | 4 | UInt32 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+FileShare.value__ |
value__ | 4 | UInt32 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+LogicalColorSpace .value__ |
Statistics
Stat | Size of instance | FieldType |
---|---|---|
Sum: | 16 | 0 |
Average: | 4 | 0 |
Minimum: | 4 | 0 |
Maximum: | 4 | 0 |
Standard deviation: | 0 | 0 |
Variance: | 0 | 0 |
210
System.Runtime .InteropServices |
|
![]() | Rule warning: Move P/Invokes to NativeMethods class |
warnif count > 0 from m in Application.Methods where
m.HasAttribute ("System.Runtime.InteropServices.DllImportAttribute".AllowNoMatch()) &&
m.ParentType.Name != "NativeMethods"
select m
// Platform Invocation methods, such as those marked
// with the System.Runtime.InteropServices.DllImportAttribute
// attribute, or methods defined by using the Declare
// keyword in Visual Basic, access unmanaged code.
// These methods should be in one of the following classes:
//
// - NativeMethods - This class does not suppress stack
// walks for unmanaged code permission.
// (System.Security.SuppressUnmanagedCodeSecurityAttribute
// must not be applied to this class.)
// This class is for methods that can be used
// anywhere because a stack walk will be performed.
//
// - SafeNativeMethods - This class suppresses
// stack walks for unmanaged code permission.
// (System.Security.SuppressUnmanagedCodeSecurityAttribute
// is applied to this class.)
// This class is for methods that are safe
// for anyone to call. Callers of these methods
// are not required to do a full security review
// to ensure that the usage is secure because
// the methods are harmless for any caller.
//
// - UnsafeNativeMethods - This class suppresses
// stack walks for unmanaged code permission.
// (System.Security.SuppressUnmanagedCodeSecurityAttribute
// is applied to this class.) This class is for
// methods that are potentially dangerous. Any
// caller of these methods must do a full security
// review to ensure that the usage is secure because
// no stack walk will be performed.
View Code Query or Rule Body
6 methods matched
methods | Full Name |
---|---|
OpenColorProfile (CmykProfileConverter+ProfileFilename ,UInt32,CmykProfileConverter+FileShare ,CmykProfileConverter+CreateDisposition) | ColorMine.ColorSpaces.Conversions .CmykProfileConverter.OpenColorProfile (CmykProfileConverter+ProfileFilename ,UInt32,CmykProfileConverter+FileShare ,CmykProfileConverter+CreateDisposition) |
CloseColorProfile(IntPtr) | ColorMine.ColorSpaces.Conversions .CmykProfileConverter.CloseColorProfile (IntPtr) |
GetStandardColorSpaceProfile(UInt32 ,CmykProfileConverter+LogicalColorSpace ,StringBuilder,UInt32&) | ColorMine.ColorSpaces.Conversions .CmykProfileConverter .GetStandardColorSpaceProfile(UInt32 ,CmykProfileConverter+LogicalColorSpace ,StringBuilder,UInt32&) |
CreateMultiProfileTransform(IntPtr[] ,UInt32,UInt32[],UInt32 ,CmykProfileConverter+ColorTransformMode ,UInt32) | ColorMine.ColorSpaces.Conversions .CmykProfileConverter .CreateMultiProfileTransform(IntPtr[] ,UInt32,UInt32[],UInt32 ,CmykProfileConverter+ColorTransformMode ,UInt32) |
DeleteColorTransform(IntPtr) | ColorMine.ColorSpaces.Conversions .CmykProfileConverter .DeleteColorTransform(IntPtr) |
TranslateColors(IntPtr ,CmykProfileConverter+RgbColor[],UInt32 ,CmykProfileConverter+ColorType ,CmykProfileConverter+CmykColor[] ,CmykProfileConverter+ColorType) | ColorMine.ColorSpaces.Conversions .CmykProfileConverter.TranslateColors (IntPtr,CmykProfileConverter+RgbColor[] ,UInt32,CmykProfileConverter+ColorType ,CmykProfileConverter+CmykColor[] ,CmykProfileConverter+ColorType) |
Statistics
Stat |
---|
Sum: |
Average: |
Minimum: |
Maximum: |
Standard deviation: |
Variance: |
010
System.Globalization |
|
![]() | Rule warning: Float and Date Parsing must be culture aware |
warnif count > 0
from m in ThirdParty.Types.WithFullNameIn(
"System.DateTime",
"System.Single",
"System.Double",
"System.Decimal").ChildMethods()
where m.NbParameters > 0 &&
(m.SimpleName == "Parse" ||
m.SimpleName == "ToString") &&
!m.Name.Contains("IFormatProvider")
select new { m, m.MethodsCallingMe }View Code Query or Rule Body
1 methods matched
method | MethodsCallingMe | Full Name |
---|---|---|
Parse(String) | 1 method | System.Double.Parse(String) |
Statistics
Stat | MethodsCallingMe |
---|---|
Sum: | 0 |
Average: | 0 |
Minimum: | 0 |
Maximum: | 0 |
Standard deviation: | 0 |
Variance: | 0 |
Object Oriented Design
|
![]() | Base class should not use derivatives |
warnif count > 0
from baseClass in JustMyCode.Types
where baseClass.IsClass && baseClass.NbChildren > 0 // <-- for optimization!
let derivedClassesUsed = baseClass.DerivedTypes.UsedBy(baseClass)
where derivedClassesUsed.Count() > 0
select new { baseClass, derivedClassesUsed }View Code Query or Rule Body
No types matched
![]() | Class shouldn't be too deep in inheritance tree |
warnif count > 0 from t in JustMyCode.Types
where t.IsClass
let baseClasses = t.BaseClasses.ExceptThirdParty()
// Warn for classes with 3 or more base classes.
// Notice that we don't count third-party classes
// because this rule concerns your code design,
// not third-party libraries consumed design.
where baseClasses.Count() >= 3
select new { t, baseClasses,
// The metric value DepthOfInheritance takes account
// of third-party base classes
t.DepthOfInheritance }
// Branches too long in the derivation should be avoided.
// See the definition of the DepthOfInheritance metric here
// http://www.ndepend.com/Metrics.aspx#DIT
View Code Query or Rule Body
No types matched
![]() | Rule warning: Class with no descendant should be sealed if possible |
warnif count > 0 from t in JustMyCode.Types where
t.IsClass &&
t.NbChildren ==0 &&
!t.IsSealed &&
!t.IsStatic
// && !t.IsPublic <-- You might want to add this condition
// if you are developing a framework
// with classes that are intended to be
// sub-classed by your clients.
orderby t.NbLinesOfCode descending
select new { t, t.NbLinesOfCode }View Code Query or Rule Body
55 types matched
types | # lines of code (LOC) | Full Name |
---|---|---|
RgbTest+To | 108 | ColorMine.Test.ColorSpaces.RgbTest+To |
CieDe2000Comparison | 56 | ColorMine.ColorSpaces.Comparisons .CieDe2000Comparison |
CmyTest+To | 30 | ColorMine.Test.ColorSpaces.CmyTest+To |
LuvTest+To | 30 | ColorMine.Test.ColorSpaces.LuvTest+To |
HsvTest+To | 30 | ColorMine.Test.ColorSpaces.HsvTest+To |
CmykProfileConverter | 29 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter |
CmykTest+To | 27 | ColorMine.Test.ColorSpaces.CmykTest+To |
HslTest+To | 27 | ColorMine.Test.ColorSpaces.HslTest+To |
HsbTest+To | 27 | ColorMine.Test.ColorSpaces.HsbTest+To |
LchTest+To | 27 | ColorMine.Test.ColorSpaces.LchTest+To |
XyzTest+To | 27 | ColorMine.Test.ColorSpaces.XyzTest+To |
CmcComparison | 25 | ColorMine.ColorSpaces.Comparisons .CmcComparison |
LabTest+To | 24 | ColorMine.Test.ColorSpaces.LabTest+To |
Cie94Comparison | 21 | ColorMine.ColorSpaces.Comparisons .Cie94Comparison |
CieDe2000ComparisonTest+Compare | 21 | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest+Compare |
CmcComparisonTest+Compare | 15 | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest+Compare |
Cie1976ComparisonTest+Compare | 15 | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest+Compare |
Cie94Comparison+ApplicationConstants | 10 | ColorMine.ColorSpaces.Comparisons .Cie94Comparison+ApplicationConstants |
Cie94ComparisonTest+Cie94ComparisonConst ructor | 10 | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Cie94ComparisonCons tructor |
HunterLabTest+To | 6 | ColorMine.Test.ColorSpaces .HunterLabTest+To |
Cie94ComparisonTest+Compare | 6 | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Compare |
Cie1976Comparison | 5 | ColorMine.ColorSpaces.Comparisons .Cie1976Comparison |
CmykProfileConverter+ProfileFilename | 4 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+ProfileFilename |
DoubleExtensionTest+BasicallyEqualTo | 4 | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo |
Cie94ComparisonTest+ApplicationConstants +ApplicationConstantsConstructor | 4 | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s+ApplicationConstantsConstructor |
Rgb | 2 | ColorMine.ColorSpaces.Rgb |
Xyz | 2 | ColorMine.ColorSpaces.Xyz |
Hsl | 2 | ColorMine.ColorSpaces.Hsl |
Lab | 2 | ColorMine.ColorSpaces.Lab |
Lch | 2 | ColorMine.ColorSpaces.Lch |
Luv | 2 | ColorMine.ColorSpaces.Luv |
Yxy | 2 | ColorMine.ColorSpaces.Yxy |
Cmy | 2 | ColorMine.ColorSpaces.Cmy |
Cmyk | 2 | ColorMine.ColorSpaces.Cmyk |
Hsv | 2 | ColorMine.ColorSpaces.Hsv |
Hsb | 2 | ColorMine.ColorSpaces.Hsb |
HunterLab | 2 | ColorMine.ColorSpaces.HunterLab |
ColorSpaceWithProfile | 0 | ColorMine.ColorSpaces .ColorSpaceWithProfile |
DoubleExtensionTest | 0 | ColorMine.Test.Utility .DoubleExtensionTest |
RgbTest | 0 | ColorMine.Test.ColorSpaces.RgbTest |
CmyTest | 0 | ColorMine.Test.ColorSpaces.CmyTest |
CmykTest | 0 | ColorMine.Test.ColorSpaces.CmykTest |
HslTest | 0 | ColorMine.Test.ColorSpaces.HslTest |
HsbTest | 0 | ColorMine.Test.ColorSpaces.HsbTest |
LabTest | 0 | ColorMine.Test.ColorSpaces.LabTest |
LchTest | 0 | ColorMine.Test.ColorSpaces.LchTest |
XyzTest | 0 | ColorMine.Test.ColorSpaces.XyzTest |
LuvTest | 0 | ColorMine.Test.ColorSpaces.LuvTest |
HsvTest | 0 | ColorMine.Test.ColorSpaces.HsvTest |
HunterLabTest | 0 | ColorMine.Test.ColorSpaces.HunterLabTest |
Cie94ComparisonTest | 0 | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest |
Cie94ComparisonTest+ApplicationConstants | 0 | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s |
CieDe2000ComparisonTest | 0 | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest |
CmcComparisonTest | 0 | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest |
Cie1976ComparisonTest | 0 | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest |
Statistics
Stat | # lines of code (LOC) |
---|---|
Sum: | 612 |
Average: | 11.13 |
Minimum: | 0 |
Maximum: | 108 |
Standard deviation: | 18.14 |
Variance: | 329.13 |
![]() | Overrides of Method() should call base.Method() |
// Overrides of Method() should refine the behavior of base.Method().
// If base.Method() is not called, the base behavior is not refined but it is replaced.
// Violations of this rule are a sign of design flaw,
// especially if the design provides valid reasons
// that advocates that the base behavior must be replaced and not refined.
//
// Discussions on this topic are available here:
// http://stackoverflow.com/questions/1107022/should-i-call-the-base-class-implementation-when-overriding-a-method-in-c-sharp
// http://stackoverflow.com/questions/2945147/make-sure-base-method-gets-called-in-c-sharp
warnif count > 0
from t in Types // Take account of third-party types too
// Bother only classes with descendant
where t.IsClass && t.NbChildren > 0
from mBase in t.InstanceMethods
where mBase.IsVirtual &&
!mBase.IsThirdParty &&
!mBase.IsAbstract &&
!mBase.IsExplicitInterfaceImpl
from mOverride in mBase.OverridesDirectDerived
where !mOverride.IsUsing(mBase)
select new { mOverride, shouldCall = mBase, definedInBaseClass = mBase.ParentType }
View Code Query or Rule Body
No methods matched
![]() | Do not hide base class methods |
// To fix a violation of this rule, remove or rename the method, or change the parameter signature
// so that the method does not hide the base method.
// More on hiding vs. virtual usefulness here:
// http://www.artima.com/intv/nonvirtual.html
// http://blogs.msdn.com/b/ericlippert/archive/2008/05/21/method-hiding-apologia.aspx
warnif count > 0
// Define a lookup table indexing methods by their name including parameters signature.
let lookup = Methods.Where(m => !m.IsConstructor && !m.IsStatic && !m.IsGeneratedByCompiler)
.ToLookup(m1 => m1.Name)
from t in Application.Types
where !t.IsStatic && t.IsClass &&
// Discard classes deriving directly from System.Object
t.DepthOfInheritance > 1
where t.BaseClasses.Any()
// For each methods not overriding any methods (new slot),
// let's check if it hides by name some methods defined in base classe.
from m in t.InstanceMethods
where m.IsNewSlot && !m.IsExplicitInterfaceImpl && !m.IsGeneratedByCompiler
// Notice how lookup is used to quickly retrieve methods with same name as m.
// This makes the query 10 times faster than iterating each base methods to check their name.
let baseMethodsHidden = lookup[m.Name].Where(m1 => m1 != m && t.DeriveFrom(m1.ParentType))
where baseMethodsHidden.Count() > 0
select new { m, baseMethodsHidden }View Code Query or Rule Body
No methods matched
![]() | Rule warning: A stateless class or structure might be turned into a static type |
// This rule indicates stateless types that might
// eventually be turned into static classes.
warnif count > 0 from t in JustMyCode.Types where
!t.IsStatic &&
!t.IsGeneric &&
t.InstanceFields.Count() == 0 &&
// Don't match:
// --> types that implement some interfaces.
t.NbInterfacesImplemented == 0 &&
// --> or classes that have sub-classes children.
t.NbChildren == 0 &&
// --> or classes that have a base class
((t.IsClass && t.DepthOfDeriveFrom("System.Object".AllowNoMatch()) == 1) ||
t.IsStructure)
select t
View Code Query or Rule Body
24 types matched
types | Full Name |
---|---|
CmykProfileConverter | ColorMine.ColorSpaces.Conversions .CmykProfileConverter |
DoubleExtensionTest | ColorMine.Test.Utility .DoubleExtensionTest |
DoubleExtensionTest+BasicallyEqualTo | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo |
RgbTest | ColorMine.Test.ColorSpaces.RgbTest |
CmyTest | ColorMine.Test.ColorSpaces.CmyTest |
CmykTest | ColorMine.Test.ColorSpaces.CmykTest |
HslTest | ColorMine.Test.ColorSpaces.HslTest |
HsbTest | ColorMine.Test.ColorSpaces.HsbTest |
LabTest | ColorMine.Test.ColorSpaces.LabTest |
LchTest | ColorMine.Test.ColorSpaces.LchTest |
XyzTest | ColorMine.Test.ColorSpaces.XyzTest |
LuvTest | ColorMine.Test.ColorSpaces.LuvTest |
HsvTest | ColorMine.Test.ColorSpaces.HsvTest |
HunterLabTest | ColorMine.Test.ColorSpaces.HunterLabTest |
Cie94ComparisonTest | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest |
Cie94ComparisonTest+ApplicationConstants | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s |
Cie94ComparisonTest+ApplicationConstants +ApplicationConstantsConstructor | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s+ApplicationConstantsConstructor |
Cie94ComparisonTest+Cie94ComparisonConst ructor | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Cie94ComparisonCons tructor |
Cie94ComparisonTest+Compare | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Compare |
CieDe2000ComparisonTest | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest |
CmcComparisonTest | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest |
CmcComparisonTest+Compare | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest+Compare |
Cie1976ComparisonTest | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest |
Cie1976ComparisonTest+Compare | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest+Compare |
Statistics
Stat |
---|
Sum: |
Average: |
Minimum: |
Maximum: |
Standard deviation: |
Variance: |
![]() | Rule warning: Non-static classes should be instantiated or turned to static |
// Notice that classes only instantiated through reflection, like plug-in root classes
// are matched by this rules.
warnif count > 0
from t in JustMyCode.Types
where t.IsClass &&
//!t.IsPublic && // if you are developing a framework,
// you might not want to match public classes
!t.IsStatic &&
!t.IsAttributeClass && // Attributes class are never seen as instantiated
!t.DeriveFrom("System.MarshalByRefObject".AllowNoMatch()) // Types instantiated through remoting infrastructure
// find the first constructor of t called
let ctorCalled = t.Constructors.FirstOrDefault(ctor => ctor.NbMethodsCallingMe > 0)
// match t if none of its constructors is called.
where ctorCalled == null
select new { t, t.Visibility }View Code Query or Rule Body
36 types matched
types | Visibility | Full Name |
---|---|---|
CmykProfileConverter | Internal | ColorMine.ColorSpaces.Conversions .CmykProfileConverter |
DoubleExtensionTest | Public | ColorMine.Test.Utility .DoubleExtensionTest |
DoubleExtensionTest+BasicallyEqualTo | Public | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo |
RgbTest | Public | ColorMine.Test.ColorSpaces.RgbTest |
RgbTest+To | Public | ColorMine.Test.ColorSpaces.RgbTest+To |
CmyTest | Public | ColorMine.Test.ColorSpaces.CmyTest |
CmyTest+To | Public | ColorMine.Test.ColorSpaces.CmyTest+To |
CmykTest | Public | ColorMine.Test.ColorSpaces.CmykTest |
CmykTest+To | Public | ColorMine.Test.ColorSpaces.CmykTest+To |
HslTest | Public | ColorMine.Test.ColorSpaces.HslTest |
HslTest+To | Public | ColorMine.Test.ColorSpaces.HslTest+To |
HsbTest | Public | ColorMine.Test.ColorSpaces.HsbTest |
HsbTest+To | Public | ColorMine.Test.ColorSpaces.HsbTest+To |
LabTest | Public | ColorMine.Test.ColorSpaces.LabTest |
LabTest+To | Public | ColorMine.Test.ColorSpaces.LabTest+To |
LchTest | Public | ColorMine.Test.ColorSpaces.LchTest |
LchTest+To | Public | ColorMine.Test.ColorSpaces.LchTest+To |
XyzTest | Public | ColorMine.Test.ColorSpaces.XyzTest |
XyzTest+To | Public | ColorMine.Test.ColorSpaces.XyzTest+To |
LuvTest | Public | ColorMine.Test.ColorSpaces.LuvTest |
LuvTest+To | Public | ColorMine.Test.ColorSpaces.LuvTest+To |
HsvTest | Public | ColorMine.Test.ColorSpaces.HsvTest |
HsvTest+To | Public | ColorMine.Test.ColorSpaces.HsvTest+To |
HunterLabTest | Public | ColorMine.Test.ColorSpaces.HunterLabTest |
HunterLabTest+To | Public | ColorMine.Test.ColorSpaces .HunterLabTest+To |
Cie94ComparisonTest | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest |
Cie94ComparisonTest+ApplicationConstants | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s |
Cie94ComparisonTest+ApplicationConstants +ApplicationConstantsConstructor | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+ApplicationConstant s+ApplicationConstantsConstructor |
Cie94ComparisonTest+Cie94ComparisonConst ructor | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Cie94ComparisonCons tructor |
Cie94ComparisonTest+Compare | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie94ComparisonTest+Compare |
CieDe2000ComparisonTest | Public | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest |
CieDe2000ComparisonTest+Compare | Public | ColorMine.Test.ColorSpaces.Comparisons .CieDe2000ComparisonTest+Compare |
CmcComparisonTest | Public | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest |
CmcComparisonTest+Compare | Public | ColorMine.Test.ColorSpaces.Comparisons .CmcComparisonTest+Compare |
Cie1976ComparisonTest | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest |
Cie1976ComparisonTest+Compare | Public | ColorMine.Test.ColorSpaces.Comparisons .Cie1976ComparisonTest+Compare |
Statistics
Stat | Visibility |
---|---|
Sum: | 0 |
Average: | 0 |
Minimum: | 0 |
Maximum: | 0 |
Standard deviation: | 0 |
Variance: | 0 |
![]() | Rule warning: Methods should be declared static if possible |
warnif count > 0
// When an instance method can be safely declared as static you should declare it as static.
// Since it doesn't use any instance data and method of its type and base-types,
// you should consider if such a method could be moved to a static utility class
// or if it is strongly related enough to its current declaring type to stay in it.
//
// Turning an instance method into a static method is a micro performance optimization
// since a static method is a bit cheaper to invoke than an instance method.
from t in JustMyCode.Types.Where(t =>
!t.IsStatic && !t.IsInterface &&
!t.IsEnumeration && !t.IsDelegate &&
!t.IsGeneratedByCompiler)
let methodsThatCanBeMadeStatic =
from m in t.InstanceMethods
// An instance method can be turned to static if it is not virtual,
// not using the this reference and also, not using
// any of its class or base classes instance fields or instance methods.
where !m.IsAbstract && !m.IsVirtual &&
!m.AccessThis && !m.IsExplicitInterfaceImpl &&
// Optimization: Using FirstOrDefault() avoid to check all members,
// as soon as one member is found
// we know the method m cannot be made static.
m.MembersUsed.FirstOrDefault(
mUsed => !mUsed.IsStatic &&
(mUsed.ParentType == t ||
t.DeriveFrom(mUsed.ParentType))
) == null
select m
from m in methodsThatCanBeMadeStatic
let staticFieldsUsed = m.ParentType.StaticFields.UsedBy(m).Where(f => !f.IsGeneratedByCompiler)
select new { m, staticFieldsUsed }View Code Query or Rule Body
134 methods matched
methods | staticFieldsUsed | Full Name |
---|---|---|
DegToRad(Double) | 0 field | ColorMine.ColorSpaces.Comparisons .CieDe2000Comparison.DegToRad(Double) |
ReturnsTrueForCloseNumbers() | 0 field | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo .ReturnsTrueForCloseNumbers() |
ReturnsFalseForFarNumbers() | 0 field | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo .ReturnsFalseForFarNumbers() |
ReturnsTrueForCloseNumbersWithDefaultPre cision() | 0 field | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo .ReturnsTrueForCloseNumbersWithDefaultPr ecision() |
ReturnsFalseForFarNumbersWithDefaultPrec ision() | 0 field | ColorMine.Test.Utility .DoubleExtensionTest+BasicallyEqualTo .ReturnsFalseForFarNumbersWithDefaultPre cision() |
WhiteRgbToCmy() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToCmy() |
WhiteRgbToCmyk() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToCmyk() |
WhiteRgbToHsl() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToHsl() |
WhiteRgbToHsb() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToHsb() |
WhiteRgbToLab() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToLab() |
WhiteRgbToLch() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToLch() |
WhiteRgbToRgb() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToRgb() |
WhiteRgbToXyz() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToXyz() |
WhiteRgbToYxy() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToYxy() |
WhiteRgbToLuv() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToLuv() |
WhiteRgbToHsv() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToHsv() |
WhiteRgbToHunterLab() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .WhiteRgbToHunterLab() |
BlackRgbToCmy() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToCmy() |
BlackRgbToCmyk() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToCmyk() |
BlackRgbToHsl() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToHsl() |
BlackRgbToHsb() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToHsb() |
BlackRgbToLab() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToLab() |
BlackRgbToLch() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToLch() |
BlackRgbToRgb() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToRgb() |
BlackRgbToXyz() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToXyz() |
BlackRgbToYxy() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToYxy() |
BlackRgbToLuv() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToLuv() |
BlackRgbToHsv() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToHsv() |
BlackRgbToHunterLab() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .BlackRgbToHunterLab() |
GoldenrodRgbToCmy() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToCmy() |
GoldenrodRgbToCmyk() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToCmyk() |
GoldenrodRgbToHsl() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToHsl() |
GoldenrodRgbToHsb() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToHsb() |
GoldenrodRgbToLab() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToLab() |
GoldenrodRgbToLch() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToLch() |
GoldenrodRgbToRgb() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToRgb() |
GoldenrodRgbToXyz() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToXyz() |
GoldenrodRgbToYxy() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToYxy() |
GoldenrodRgbToLuv() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToLuv() |
GoldenrodRgbToHsv() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToHsv() |
GoldenrodRgbToHunterLab() | 0 field | ColorMine.Test.ColorSpaces.RgbTest+To .GoldenrodRgbToHunterLab() |
SteelBlueCmyToCmy() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToCmy() |
SteelBlueCmyToCmyk() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToCmyk() |
SteelBlueCmyToHsl() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToHsl() |
SteelBlueCmyToHsb() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToHsb() |
SteelBlueCmyToLab() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToLab() |
SteelBlueCmyToLch() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToLch() |
SteelBlueCmyToRgb() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToRgb() |
SteelBlueCmyToXyz() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToXyz() |
SteelBlueCmyToYxy() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToYxy() |
SteelBlueCmyToLuv() | 0 field | ColorMine.Test.ColorSpaces.CmyTest+To .SteelBlueCmyToLuv() |
DarkVioletCmykToCmy() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToCmy() |
DarkVioletCmykToCmyk() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToCmyk() |
DarkVioletCmykToHsl() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToHsl() |
DarkVioletCmykToHsb() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToHsb() |
DarkVioletCmykToLab() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToLab() |
DarkVioletCmykToLch() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToLch() |
DarkVioletCmykToRgb() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToRgb() |
DarkVioletCmykToXyz() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToXyz() |
DarkVioletCmykToYxy() | 0 field | ColorMine.Test.ColorSpaces.CmykTest+To .DarkVioletCmykToYxy() |
AliceBlueHslToCmy() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToCmy() |
AliceBlueHslToCmyk() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToCmyk() |
AliceBlueHslToHsl() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToHsl() |
AliceBlueHslToHsb() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToHsb() |
AliceBlueHslToLab() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToLab() |
AliceBlueHslToLch() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToLch() |
AliceBlueHslToRgb() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToRgb() |
AliceBlueHslToXyz() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToXyz() |
AliceBlueHslToYxy() | 0 field | ColorMine.Test.ColorSpaces.HslTest+To .AliceBlueHslToYxy() |
AliceBlueHsbToCmy() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToCmy() |
AliceBlueHsbToCmyk() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToCmyk() |
AliceBlueHsbToHsl() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToHsl() |
AliceBlueHsbToHsb() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToHsb() |
AliceBlueHsbToLab() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToLab() |
AliceBlueHsbToLch() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToLch() |
AliceBlueHsbToRgb() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToRgb() |
AliceBlueHsbToXyz() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToXyz() |
AliceBlueHsbToYxy() | 0 field | ColorMine.Test.ColorSpaces.HsbTest+To .AliceBlueHsbToYxy() |
RedLabToCmy() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToCmy() |
RedLabToCmyk() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToCmyk() |
RedLabToHsl() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToHsl() |
RedLabToLab() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToLab() |
RedLabToLch() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToLch() |
RedLabToRgb() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToRgb() |
RedLabToXyz() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToXyz() |
RedLabToYxy() | 0 field | ColorMine.Test.ColorSpaces.LabTest+To .RedLabToYxy() |
MaroonLchToCmy() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToCmy() |
MaroonLchToCmyk() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToCmyk() |
MaroonLchToHsl() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToHsl() |
MaroonLchToHsb() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToHsb() |
MaroonLchToLab() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToLab() |
MaroonLchToLch() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToLch() |
MaroonLchToRgb() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToRgb() |
MaroonLchToXyz() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToXyz() |
MaroonLchToYxy() | 0 field | ColorMine.Test.ColorSpaces.LchTest+To .MaroonLchToYxy() |
RivergumXyzToCmy() | 0 field | ColorMine.Test.ColorSpaces.XyzTest+To .RivergumXyzToCmy() |
RivergumXyzToCmyk() | 0 field | ColorMine.Test.ColorSpaces.XyzTest+To .RivergumXyzToCmyk() |
RivergumXyzToHsl() | 0 field | ColorMine.Test.ColorSpaces.XyzTest+To .RivergumXyzToHsl() |
RivergumXyzToHsb() | 0 field | ColorMine.Test.ColorSpaces.XyzTest+To .RivergumXyzToHsb() |
RivergumXyzToLab() | 0 field | ColorMine.Test.ColorSpaces.XyzTest+To .RivergumXyzToLab() |
Statistics
Stat | staticFieldsUsed |
---|---|
Sum: | 0 |
Average: | 0 |
Minimum: | 0 |
Maximum: | 0 |
Standard deviation: | 0 |
Variance: | 0 |
![]() | Constructor should not call a virtual methods |
// Returns constructor of a non-sealed type calling virtual methods.
// In such a situation, if a derived class overrides the method,
// then the override method will be called before the derived constructor.
// This makes the class fragile to derive from.
//
// Violations reported can be solved by re-designing object initialisation
// or by marking the parent class as sealed, if possible.
warnif count > 0
from t in Application.Types where
t.IsClass &&
!t.IsGeneratedByCompiler &&
!t.IsSealed
from ctor in t.Constructors
let virtualMethodsCalled = from mCalled in ctor.MethodsCalled
where mCalled.IsVirtual &&
(mCalled.ParentType == t ||
t.DeriveFrom(mCalled.ParentType))
select mCalled
where virtualMethodsCalled.Count() > 0
select new { ctor ,
virtualMethodsCalled,
// If there is no derived type, it might be
// an opportunity to mark t as sealed.
t.DerivedTypes }View Code Query or Rule Body
No methods matched
![]() | Avoid the Singleton pattern |
warnif count > 0
from t in Application.Types
where !t.IsStatic && !t.IsAbstract && (t.IsClass || t.IsStructure)
// All ctors of a singleton are private
where t.Constructors.Where(ctor => !ctor.IsPrivate).Count() == 0
// A singleton contains one static field of its parent type, to reference the unique instance
let staticFieldInstances = t.StaticFields.WithFieldType(t)
where staticFieldInstances.Count() == 1
select new { t, staticFieldInstance = staticFieldInstances.First() }
// The Singleton pattern consists in syntactically enforcing that a class
// has just one unique instance.
// At first glance, this pattern looks appealing and it is widely used.
// However, we discourage you from using singleton classes because experience
// shows that singletons often result in less testable and less maintainable code.
// More details available in these discussions:
// http://codebetter.com/patricksmacchia/2011/05/04/back-to-basics-usage-of-static-members/
// http://adamschepis.com/blog/2011/05/02/im-adam-and-im-a-recovering-singleton-addict/
View Code Query or Rule Body
No types matched
![]() | Don't assign static fields from instance methods |
// Assigning static fields from instance methods leads to
// poorly maintainable and non thread-safe code.
// It is advised to assign static fields inline or from class constructor.
warnif count > 0
from f in Application.Fields where
f.IsStatic &&
!f.IsLiteral &&
!f.IsInitOnly &&
!f.IsGeneratedByCompiler &&
// Contract API define such a insideContractEvaluation static field
f.Name != "insideContractEvaluation"
let assignedBy = f.MethodsAssigningMe.Where(m => !m.IsStatic)
where assignedBy .Count() > 0
select new { f, assignedBy }View Code Query or Rule Body
No fields matched
![]() | Avoid empty interfaces |
warnif count > 0 from t in JustMyCode.Types where
t.IsInterface &&
t.NbMethods == 0
select new { t, t.TypesThatImplementMe }
// Interfaces define members that provide a behavior
// or usage contract. The functionality described by
// the interface can be adopted by any type,
// regardless of where the type appears in the
// inheritance hierarchy. A type implements an
// interface by providing implementations for the
// interface's members. An empty interface does not
// define any members, and as such, does not define
// a contract that can be implemented.
// If your design includes empty interfaces that
// types are expected to implement, you are probably
// using an interface as a marker, or a way of
// identifying a group of types. If this identification
// will occur at runtime, the correct way to accomplish
// this is to use a custom attribute. Use the presence
// or absence of the attribute, or the attribute's
// properties, to identify the target types. If the
// identification must occurs at compile time, then using
// an empty interface is acceptable.View Code Query or Rule Body
No types matched
![]() | Avoid types initialization cycles |
warnif count > 0
// The class constructor (also called static constructor, and named cctor in IL code)
// of a type, if any, is executed by the CLR at runtime, the first time the type is used.
// A cctor doesn't need to be explicitely declared in C# or VB.NET, to exist in compiled IL code.
// Having a static field inline initialization is enought to have
// the cctor implicitely declared in the parent class or structure.
//
// If the cctor of a type t1 is using the type t2 and if the cctor of t2 is using t1,
// some type initialization unexpected and hard-to-diagnose buggy behavior can occur.
// Such a cyclic chain of initialization is not necessarily limited to two types
// and can embrace N types in the general case.
// More information on types initialization cycles can be found here:
// http://msmvps.com/blogs/jon_skeet/archive/2012/04/07/1808561.aspx
// The present code rule enumerates types initialization cycles.
// Some false positives can appear if some lambda expressions are defined
// in cctors or in methods called by cctors. In such situation, this rule
// considers these lambda expressions as executed at type initialization time,
// while it is not necessarily the case.
// Types initialization cycle can only happen between types of an assembly.
from assembly in Application.Assemblies
let cctorSuspects = assembly.ChildMethods.Where(
m => m.IsClassConstructor &&
// Optimization: types involved in a type cycle necessarily don't have type level.
m.ParentType.Level == null)
where cctorSuspects.Count() > 1
let typesSuspects = cctorSuspects.ParentTypes().ToHashSet()
//
// dicoTmp associates to each type suspect T, a set of types from typesSuspects
// that contains at least a method or a field used directly or indirectly by the cctor of T.
//
let dicoTmp = cctorSuspects.ToDictionary(
cctor => cctor.ParentType,
cctor => ((IMember)cctor).ToEnumerable().FillIterative(
members => from m in members
from mUsed in (m is IMethod) ? (m as IMethod).MembersUsed : new IMember[0]
where mUsed.ParentAssembly == assembly
select mUsed)
.DefinitionDomain
.Select(m => m.ParentType) // Don't need .Distinct() here, because of ToHashSet() below.
.Except(cctor.ParentType)
.Intersect(typesSuspects)
.ToHashSet()
)
//
// dico associates to each type suspect T, the set of types initialized (directly or indirectly)
// by the initialization of T. This second step is needed, because if a cctor of a type T1
// calls a member of a type T2, not only the cctor of T1 triggers the initialization of T2,
// but also it triggers the initialization of all types that are initialized by T2 initialization.
//
let dico = typesSuspects.Where(t => dicoTmp[t].Count() > 0).ToDictionary(
typeSuspect => typeSuspect,
typeSuspect => typeSuspect.ToEnumerable().FillIterative(
types => from t in types
from tUsed in dicoTmp[t]
select tUsed)
.DefinitionDomain
.Except(typeSuspect)
.ToHashSet()
)
//
// Now that dico is prepared, detect the cctor cycles
//
from t in dico.Keys
// Thanks to the work done to build dico, it is now pretty easy
// to spot types involved in an initialization cyle with t!
let usersAndUseds = from tTmp in dico[t]
where dico.ContainsKey(tTmp) && dico[tTmp].Contains(t)
select tTmp
where usersAndUseds.Count() > 0
// Here we've found type(s) both using and used by the suspect type.
// A cycle involving the type t is found!
let typeInitCycle = usersAndUseds.Append(t)
// Compute methodsCalled and fieldsUsed, useful to explore
// how a cctor involved in a type initialization cycle, triggers other type initialization.
let methodsCalledDepth = assembly.ChildMethods.DepthOfIsUsedBy(t.ClassConstructor)
let fieldsUsedDepth = assembly.ChildFields.DepthOfIsUsedBy(t.ClassConstructor)
let methodsCalled = methodsCalledDepth.DefinitionDomain.OrderBy(m => methodsCalledDepth[m]).ToArray()
let fieldsUsed = fieldsUsedDepth.DefinitionDomain.OrderBy(f => fieldsUsedDepth[f]).ToArray()
// Use the tick box to: Group cctors methods By parent types
select new { t.ClassConstructor,
cctorsCycle= typeInitCycle.Select(tTmp => tTmp.ClassConstructor),
// methodsCalled and fieldsUsed are members used directly and indirectly by the cctor.
// Export these members to the dependency graph (right click the cell Export/Append ... to the Graph)
// and see how the cctor trigger the initialization of other types
methodsCalled,
fieldsUsed
}View Code Query or Rule Body
No methods matched
API Breaking Changes
|
![]() | API Breaking Changes: Types |
// This rule warns if a publicly visible type is
// not publicly visible anymore or if it has been removed.
// Such type can break the code of your clients.
warnif count > 0 from t in codeBase.OlderVersion().Application.Types
where t.IsPubliclyVisible &&
// The type has been removed and its parent assembly hasn't been removed ...
( (t.WasRemoved() && !t.ParentAssembly.WasRemoved()) ||
// ... or the type is not publicly visible anymore
!t.WasRemoved() && !t.NewerVersion().IsPubliclyVisible)
select new { t,
NewVisibility = (t.WasRemoved() ? " " : t.NewerVersion().Visibility.ToString()) }
View Code Query or Rule Body
No types matched
![]() | API Breaking Changes: Methods |
// This rule warns if a publicly visible method is
// not publicly visible anymore or if it has been removed.
// Such method can break the code of your clients.
warnif count > 0 from m in codeBase.OlderVersion().Application.Methods
where m.IsPubliclyVisible &&
// The method has been removed and its parent type hasn't been removed ...
( (m.WasRemoved() && !m.ParentType.WasRemoved()) ||
// ... or the method is not publicly visible anymore
!m.WasRemoved() && !m.NewerVersion().IsPubliclyVisible)
select new { m,
NewVisibility = (m.WasRemoved() ? " " : m.NewerVersion().Visibility.ToString()) }View Code Query or Rule Body
No methods matched
![]() | API Breaking Changes: Fields |
// This rule warns if a publicly visible field is
// not publicly visible anymore or if it has been removed.
// Such field can break the code of your clients.
warnif count > 0 from f in codeBase.OlderVersion().Application.Fields
where f.IsPubliclyVisible &&
// The field has been removed and its parent type hasn't been removed ...
( (f.WasRemoved() && !f.ParentType.WasRemoved()) ||
// ... or the field is not publicly visible anymore
!f.WasRemoved() && !f.NewerVersion().IsPubliclyVisible)
select new { f,
NewVisibility = (f.WasRemoved() ? " " : f.NewerVersion().Visibility.ToString()) }View Code Query or Rule Body
No fields matched
![]() | API Breaking Changes: Interfaces and Abstract Classes |
// This rule warns if a publicly visible interface or abstract class
// has been changed and contains new abstract methods or
// if some abstract methods have been removed.
// This can break the code of clients
// that implement such interface or derive from such abstract class.
warnif count > 0 from tNewer in Application.Types where
(tNewer.IsInterface || tNewer.IsClass && tNewer.IsAbstract) &&
tNewer.IsPubliclyVisible &&
tNewer.IsPresentInBothBuilds()
let tOlder = tNewer.OlderVersion() where tOlder.IsPubliclyVisible
let methodsRemoved = tOlder.Methods.Where(m => m.IsAbstract && m.WasRemoved())
let methodsAdded = tNewer.Methods.Where(m => m.IsAbstract && m.WasAdded())
where methodsAdded.Count() > 0 || methodsRemoved.Count() > 0
select new { tNewer, methodsAdded, methodsRemoved }View Code Query or Rule Body
No types matched
![]() | Broken serializable types |
// Find breaking changes in types marked with SerializableAttribute.
warnif count > 0
from t in Application.Types where
// Collect types tagged with SerializableAttribute
t.HasAttribute("System.SerializableAttribute".AllowNoMatch()) &&
!t.IsDelegate &&
t.IsPresentInBothBuilds() &&
t.HasAttribute(t)
// Find newer and older versions of NonSerializedAttribute
let newNonSerializedAttribute = ThirdParty.Types.WithFullName("System.NonSerializedAttribute").SingleOrDefault()
let oldNonSerializedAttribute = newNonSerializedAttribute == null ? null : newNonSerializedAttribute.OlderVersion()
// Find added or removed fields not marked with NonSerializedAttribute
let addedInstanceField = from f in t.InstanceFields where
f.WasAdded() &&
(newNonSerializedAttribute == null || !f.HasAttribute(newNonSerializedAttribute))
select f
let removedInstanceField = from f in t.OlderVersion().InstanceFields where
f.WasRemoved() &&
(oldNonSerializedAttribute == null || !f.HasAttribute(oldNonSerializedAttribute))
select f
where addedInstanceField.Count() > 0 || removedInstanceField.Count() > 0
select new { t, addedInstanceField, removedInstanceField }
// From http://msdn.microsoft.com/library/system.serializableattribute.aspx :
// All the public and private fields in a type that are marked by the
// SerializableAttribute are serialized by default, unless the type
// implements the ISerializable interface to override the serialization process.
// The default serialization process excludes fields that are marked
// with the NonSerializedAttribute attribute.View Code Query or Rule Body
No types matched
![]() | Avoid transforming immutable types into mutable types |
// Immutability is a strong property on a type.
// Breaking immutability can result in serious problem for an algorithm consummer
// that has been written taking account of the type immutability.
// To visualize changes in code, right-click a matched type and select:
// - Compare older and newer versions of source file
// - Compare older and newer versions disassembled with Reflector
warnif count > 0
from t in Application.Types where
t.IsPresentInBothBuilds() &&
!t.IsStatic &&
!t.IsImmutable &&
t.OlderVersion().IsImmutable
let mutableFields = from f in t.InstanceFields where !f.IsImmutable select f
select new { t, mutableFields }
View Code Query or Rule Body
No types matched
![]() | Avoid changing enumerations Flags status |
// Being tagged with the Flags attribute is a strong property for an enumeration.
// Changing the Flags status of an enumeration has significant impact for its client.
warnif count > 0
let oldFlags = codeBase.OlderVersion().ThirdParty.Types.WithFullName("System.FlagsAttribute").SingleOrDefault()
let newFlags = ThirdParty.Types.WithFullName("System.FlagsAttribute").SingleOrDefault()
where oldFlags != null && newFlags != null
from t in Application.Types where
t.IsEnumeration &&
t.IsPresentInBothBuilds()
let isFlags = t.HasAttribute(newFlags)
let wasFlags = t.OlderVersion().HasAttribute(oldFlags)
where isFlags != wasFlags
select new { t, isFlags, wasFlags }
View Code Query or Rule Body
No types matched
![]() | API: New publicly visible types |
// List types that are new in the public surface of your assemblies
from t in Application.Types
where t.IsPubliclyVisible &&
// The type has been removed and its parent assembly hasn't been removed ...
( (t.WasAdded() && !t.ParentAssembly.WasAdded()) ||
// ... or the type existed but was not publicly visible
!t.WasAdded() && !t.OlderVersion().IsPubliclyVisible)
select new { t,
OldVisibility = (t.WasAdded() ? " " : t.OlderVersion().Visibility.ToString()) }View Code Query or Rule Body
No types matched
![]() | API: New publicly visible methods |
// List methods that are new in the public surface of your assemblies
from m in Application.Methods
where m.IsPubliclyVisible &&
// The method has been removed and its parent assembly hasn'm been removed ...
( (m.WasAdded() && !m.ParentType.WasAdded()) ||
// ... or the t existed but was not publicly visible
!m.WasAdded() && !m.OlderVersion().IsPubliclyVisible)
select new { m,
OldVisibility = (m.WasAdded() ? " " : m.OlderVersion().Visibility.ToString()) }View Code Query or Rule Body
No methods matched
![]() | API: New publicly visible fields |
// List fields that are new in the public surface of your assemblies
from f in Application.Fields
where f.IsPubliclyVisible &&
// The method has been removed and its parent assembly hasn'f been removed ...
( (f.WasAdded() && !f.ParentType.WasAdded()) ||
// ... or the t existed but was not publicly visible
!f.WasAdded() && !f.OlderVersion().IsPubliclyVisible)
select new { f,
OldVisibility = (f.WasAdded() ? " " : f.OlderVersion().Visibility.ToString()) }View Code Query or Rule Body
No fields matched
Code Diff Summary
|
![]() | New assemblies |
from a in Application.Assemblies where a.WasAdded()
select new { a, a.NbLinesOfCode }
View Code Query or Rule Body
No assemblies matched
![]() | Assemblies removed |
from a in codeBase.OlderVersion().Application.Assemblies where a.WasRemoved()
select new { a, a.NbLinesOfCode }View Code Query or Rule Body
No assemblies matched
![]() | Assemblies where code was changed |
from a in Application.Assemblies where a.CodeWasChanged()
select new { a, a.NbLinesOfCode,
oldNbLinesOfCode = a.OlderVersion().NbLinesOfCode.GetValueOrDefault() ,
delta = (int) a.NbLinesOfCode.GetValueOrDefault() - a.OlderVersion().NbLinesOfCode.GetValueOrDefault() }View Code Query or Rule Body
No assemblies matched
![]() | New namespaces |
from n in Application.Namespaces where
!n.ParentAssembly.WasAdded() &&
n.WasAdded()
select new { n, n.NbLinesOfCode }
View Code Query or Rule Body
No namespaces matched
![]() | Namespaces removed |
from n in codeBase.OlderVersion().Application.Namespaces where
!n.ParentAssembly.WasRemoved() &&
n.WasRemoved()
select new { n, n.NbLinesOfCode }
View Code Query or Rule Body
No namespaces matched
![]() | Namespaces where code was changed |
from n in Application.Namespaces where n.CodeWasChanged()
select new { n, n.NbLinesOfCode,
oldNbLinesOfCode = n.OlderVersion().NbLinesOfCode.GetValueOrDefault() ,
delta = (int) n.NbLinesOfCode.GetValueOrDefault() - n.OlderVersion().NbLinesOfCode.GetValueOrDefault() }View Code Query or Rule Body
No namespaces matched
![]() | New types |
from t in Application.Types where
!t.ParentNamespace.WasAdded() &&
t.WasAdded()
select new { t, t.NbLinesOfCode }
View Code Query or Rule Body
No types matched
![]() | Types removed |
from t in codeBase.OlderVersion().Application.Types where
!t.ParentNamespace.WasRemoved() &&
t.WasRemoved()
select new { t, t.NbLinesOfCode }
View Code Query or Rule Body
No types matched
![]() | Types where code was changed |
// To visualize changes in code, right-click a matched type and select:
// - Compare older and newer versions of source file
// - Compare older and newer versions disassembled with Reflector
from t in Application.Types where t.CodeWasChanged()
//select new { t, t.NbLinesOfCode }
select new { t, t.NbLinesOfCode,
oldNbLinesOfCode = t.OlderVersion().NbLinesOfCode ,
delta = (int?) t.NbLinesOfCode - t.OlderVersion().NbLinesOfCode }
/*from t in Application.Types where t.CodeWasChanged() && t.IsPresentInBothBuild
select new { t, t.NbLinesOfCode,
oldNbLinesOfCode = t.OlderVersion().NbLinesOfCode ,
delta = (int) t.NbLinesOfCode - t.OlderVersion().NbLinesOfCode }*/View Code Query or Rule Body
No types matched
![]() | Heuristic to find types moved from one namespace or assembly to another |
let typesRemoved = codeBase.OlderVersion().Types.Where(t => t.WasRemoved())
let typesAdded = Types.Where(t => t.WasAdded())
from tMoved in typesAdded.Join(
typesRemoved,
t => t.Name,
t => t.Name,
(tNewer, tOlder) => new { tNewer,
OlderParentNamespace = tOlder.ParentNamespace,
OlderParentAssembly = tOlder.ParentAssembly } )
select tMovedView Code Query or Rule Body
No types matched
![]() | Types directly using one or several types changed |
let typesChanged = Application.Types.Where(t => t.CodeWasChanged()).ToHashSet()
from t in JustMyCode.Types.UsingAny(typesChanged) where
!t.CodeWasChanged() &&
!t.WasAdded()
let typesChangedUsed = t.TypesUsed.Intersect(typesChanged)
select new { t, typesChangedUsed }View Code Query or Rule Body
No types matched
![]() | Types indirectly using one or several types changed |
let typesChanged = Application.Types.Where(t => t.CodeWasChanged()).ToHashSet()
// 'depth' represents a code metric defined on types using
// directly or indirectly any type where code was changed.
let depth = JustMyCode.Types.DepthOfIsUsingAny(typesChanged)
from t in depth.DefinitionDomain where
!t.CodeWasChanged() &&
!t.WasAdded()
let typesChangedDirectlyUsed = t.TypesUsed.Intersect(typesChanged)
let depthOfUsingTypesChanged = depth[t]
orderby depthOfUsingTypesChanged
select new { t, depthOfUsingTypesChanged, typesChangedDirectlyUsed }View Code Query or Rule Body
No types matched
![]() | New methods |
from m in Application.Methods where
!m.ParentType.WasAdded() &&
m.WasAdded()
select new { m, m.NbLinesOfCode }
View Code Query or Rule Body
No methods matched
![]() | Methods removed |
from m in codeBase.OlderVersion().Application.Methods where
!m.ParentType.WasRemoved() &&
m.WasRemoved()
select new { m, m.NbLinesOfCode }
View Code Query or Rule Body
No methods matched
![]() | Methods where code was changed |
// To visualize changes in code, right-click a matched method and select:
// - Compare older and newer versions of source file
// - Compare older and newer versions disassembled with Reflector
from m in Application.Methods where m.CodeWasChanged()
select new { m, m.NbLinesOfCode,
oldNbLinesOfCode = m.OlderVersion().NbLinesOfCode ,
delta = (int?) m.NbLinesOfCode - m.OlderVersion().NbLinesOfCode }View Code Query or Rule Body
No methods matched
![]() | Methods directly calling one or several methods changed |
let methodsChanged = Application.Methods.Where(m => m.CodeWasChanged()).ToHashSet()
from m in JustMyCode.Methods.UsingAny(methodsChanged ) where
!m.CodeWasChanged() &&
!m.WasAdded()
let methodsChangedCalled = m.MethodsCalled.Intersect(methodsChanged)
select new { m, methodsChangedCalled }View Code Query or Rule Body
No methods matched
![]() | Methods indirectly calling one or several methods changed |
let methodsChanged = Application.Methods.Where(m => m.CodeWasChanged()).ToHashSet()
// 'depth' represents a code metric defined on methods using
// directly or indirectly any method where code was changed.
let depth = JustMyCode.Methods.DepthOfIsUsingAny(methodsChanged)
from m in depth.DefinitionDomain where
!m.CodeWasChanged() &&
!m.WasAdded()
let methodsChangedDirectlyUsed = m.MethodsCalled.Intersect(methodsChanged)
let depthOfUsingMethodsChanged = depth[m]
orderby depthOfUsingMethodsChanged
select new { m, depthOfUsingMethodsChanged, methodsChangedDirectlyUsed }View Code Query or Rule Body
No methods matched
![]() | New fields |
from f in Application.Fields where
!f.ParentType.WasAdded() &&
f.WasAdded()
select new { f }
View Code Query or Rule Body
No fields matched
![]() | Fields removed |
from f in codeBase.OlderVersion().Application.Fields where
!f.ParentType.WasRemoved() &&
f.WasRemoved()
select new { f }
View Code Query or Rule Body
No fields matched
![]() | Third party types that were not used and that are now used |
from t in ThirdParty.Types where t.IsUsedRecently()
select new { t, t.Methods, t.Fields, t.TypesUsingMe }
View Code Query or Rule Body
No types matched
![]() | Third party types that were used and that are not used anymore |
from t in codeBase.OlderVersion().Types where t.IsNotUsedAnymore()
select new { t, t.Methods, t.Fields, TypesThatUsedMe = t.TypesUsingMe }
View Code Query or Rule Body
No types matched
![]() | Third party methods that were not used and that are now used |
from m in ThirdParty.Methods where
m.IsUsedRecently() &&
!m.ParentType.IsUsedRecently()
select new { m, m.MethodsCallingMe }View Code Query or Rule Body
No methods matched
![]() | Third party methods that were used and that are not used anymore |
from m in codeBase.OlderVersion().Methods where
m.IsNotUsedAnymore() &&
!m.ParentType.IsNotUsedAnymore()
select new { m, MethodsThatCalledMe = m.MethodsCallingMe}View Code Query or Rule Body
No methods matched
![]() | Third party fields that were not used and that are now used |
from f in ThirdParty.Fields where
f.IsUsedRecently() &&
!f.ParentType.IsUsedRecently()
select new { f, f.MethodsUsingMe }View Code Query or Rule Body
No fields matched
![]() | Third party fields that were used and that are not used anymore |
from f in codeBase.OlderVersion().Fields where
f.IsNotUsedAnymore() &&
!f.ParentType.IsNotUsedAnymore()
select new { f, MethodsThatUsedMe = f.MethodsUsingMe }View Code Query or Rule Body
No fields matched
Test and Code Coverage
|
![]() | C.R.A.P method code metric |
// Change Risk Analyzer and Predictor (i.e. CRAP) code metric
// This code metric helps in pinpointing overly complex and untested code.
// Reference: http://www.artima.com/weblogs/viewpost.jsp?thread=215899
// Formula: CRAP(m) = comp(m)^2 * (1 – cov(m)/100)^3 + comp(m)
warnif count > 0
from m in JustMyCode.Methods
// Don't match too short methods
where m.NbLinesOfCode > 10
let CC = m.CyclomaticComplexity
let uncov = (100 - m.PercentageCoverage) / 100f
let CRAP = (CC * CC * uncov * uncov * uncov) + CC
where CRAP != null && CRAP > 30
orderby CRAP descending, m.NbLinesOfCode descending
select new { m, CRAP, CC, uncoveredPercentage = uncov*100, m.NbLinesOfCode }View Code Query or Rule Body
No methods matched
![]() | Complex methods partially covered by tests should be 100% covered |
warnif count > 0 from m in JustMyCode.Methods
where
// These metrics' definitions are available here:
// http://www.ndepend.com/Metrics.aspx#MetricsOnMethods
( m.NbLinesOfCode > 30 ||
m.ILCyclomaticComplexity > 50 ||
m.ILNestingDepth > 4 ||
m.NbVariables > 8) &&
// Take care only of complex methods
// already partially covered, but not completely covered.
m.PercentageCoverage > 0 &&
m.PercentageCoverage < 100
orderby m.NbLinesOfCodeNotCovered ascending,
m.NbLinesOfCode descending
select new { m, m.PercentageCoverage, m.NbLinesOfCode,
m.NbLinesOfCodeCovered, m.NbLinesOfCodeNotCovered,
m.ILCyclomaticComplexity, m.ILNestingDepth, m.NbVariables } View Code Query or Rule Body
No methods matched
![]() | Method changed poorly covered |
from m in Application.Methods where
m.PercentageCoverage < 30 &&
m.CodeWasChanged()
orderby m.NbLinesOfCode descending,
m.NbLinesOfCodeNotCovered ,
m.PercentageCoverage
select new { m, m.PercentageCoverage, m.NbLinesOfCode,
m.NbLinesOfCodeNotCovered }
View Code Query or Rule Body
No methods matched
![]() | Method added poorly covered |
from m in Application.Methods where
m.NbLinesOfCode > 0 &&
m.PercentageCoverage < 30 &&
m.WasAdded()
orderby m.NbLinesOfCode descending,
m.NbLinesOfCodeNotCovered ,
m.PercentageCoverage
select new { m, m.PercentageCoverage, m.NbLinesOfCode,
m.NbLinesOfCodeNotCovered }
View Code Query or Rule Body
No methods matched
![]() | Types 95% to 99% covered |
from t in Application.Types where
t.PercentageCoverage >= 95 &&
t.PercentageCoverage <= 99 &&
!t.IsGeneratedByCompiler
let methodsCulprit = t.Methods.Where(m => m.PercentageCoverage < 100)
orderby t.NbLinesOfCode descending ,
t.NbLinesOfCodeNotCovered ,
t.PercentageCoverage
select new { t, t.PercentageCoverage, t.NbLinesOfCode,
t.NbLinesOfCodeNotCovered, methodsCulprit }
// Having types 100% covered by tests is a good idea because
// the small portion of code hard to cover, is also the
// portion of code that is the most likely to contain bugs.
View Code Query or Rule Body
No types matched
![]() | Namespaces 95% to 99% covered |
from n in Application.Namespaces where
n.PercentageCoverage >= 95 &&
n.PercentageCoverage <= 99
let methodsCulprit = n.ChildMethods.Where(m => m.PercentageCoverage < 100)
orderby n.NbLinesOfCode descending ,
n.NbLinesOfCodeNotCovered ,
n.PercentageCoverage
select new { n, n.PercentageCoverage, n.NbLinesOfCode,
n.NbLinesOfCodeNotCovered, methodsCulprit }
// Having types 100% covered by tests is a good idea because
// the small portion of code hard to cover, is also the
// portion of code that is the most likely to contain bugs.View Code Query or Rule Body
No namespaces matched
![]() | Types tagged with FullCoveredAttribute should be 100% covered |
warnif count > 0
from t in Application.Types where
t.HasAttribute ("NDepend.Attributes.FullCoveredAttribute".AllowNoMatch()) &&
t.PercentageCoverage < 100
let notFullCoveredMethods = t.Methods.Where(
m => m.NbLinesOfCode> 0 &&
m.PercentageCoverage < 100 &&
!m.HasAttribute("NDepend.Attributes.UncoverableByTestAttribute".AllowNoMatch()))
orderby t.NbLinesOfCodeNotCovered descending
select new { t, t.PercentageCoverage, t.NbLinesOfCodeNotCovered, notFullCoveredMethods,
t.NbLinesOfCode, t.NbLinesOfCodeCovered }
// By using a FullCoveredAttribute, you can signify to developers
// that a class is, and must remain in the future, 100% covered by tests.
// If you don't want to link NDepend.API.dll,
// you can use your own attribute and adapt this rule.
// Having types 100% covered by tests is a good idea because
// the small portion of code hard to cover, is also the
// portion of code that is the most likely to contain bugs.
View Code Query or Rule Body
No types matched
![]() | Types 100% covered should be tagged with FullCoveredAttribute |
warnif count > 0 from t in JustMyCode.Types where
!t.HasAttribute ("NDepend.Attributes.FullCoveredAttribute".AllowNoMatch()) &&
t.PercentageCoverage == 100 &&
!t.IsGeneratedByCompiler
select new { t, t.NbLinesOfCode }
// By using a FullCoveredAttribute, you can signify to developers
// that a class is, and must remain in the future, 100% covered by tests.
// If you don't want to link NDepend.API.dll, you can use your own attribute and adapt this rule.
// Having types 100% covered by tests is a good idea because
// the small portion of code hard to cover, is also the
// portion of code that is the most likely to contain bugs.
View Code Query or Rule Body
No types matched
![]() | Types not covered at all |
from t in Application.Types where
t.PercentageCoverage == 0
orderby t.NbLinesOfCode descending
select new { t, t.NbLinesOfCode }
View Code Query or Rule Body
No types matched
![]() | Namespaces not covered at all |
from n in Application.Namespaces where
n.PercentageCoverage == 0
orderby n.NbLinesOfCode descending
select new { n, n.NbLinesOfCode}
View Code Query or Rule Body
No namespaces matched
![]() | Test Methods |
// We advise to not include test assemblies in code analyzed by NDepend.
// But if you wish the current query to run properly,
// you'll need to consider test assemblies in your list of application assemblies analyzed by NDepend..
let testAttr = ThirdParty.Types.WithNameIn("TestAttribute", "TestCaseAttribute")
let testMethods = Methods.TaggedWithAnyAttributes(testAttr)
from m in testMethods
select m
View Code Query or Rule Body
No methods matched
![]() | Methods directly called by test Methods |
// Lists all methods directly called by tests methods.
// Overrides of virtual and absract methods, called through polymorphism, are not listed.
// Methods solely invoked through a delegate are not listed.
// Methods solely invoked through reflection are not listed.
// We advise to not include test assemblies in code analyzed by NDepend.
// But if you wish the current query to run properly,
// you'll need to consider test assemblies in your list of application assemblies analyzed by NDepend..
let testAttr = ThirdParty.Types.WithNameIn("TestAttribute", "TestCaseAttribute")
let testMethods = Methods.TaggedWithAnyAttributes(testAttr).ToHashSet()
// --- Uncomment this line if your test methods are in dedicated test assemblies ---
//let testAssemblies = testMethods.ParentAssemblies().ToHashSet()
from m in Application.Methods.UsedByAny(testMethods)
// --- Uncomment this line if your test methods are in dedicated test assemblies ---
//where !testAssemblies.Contains(m.ParentAssembly)
select new { m ,
calledByTests = m.MethodsCallingMe.Intersect(testMethods ),
// --- Uncomment this line if your project import some coverage data ---
// m.PercentageCoverage
}View Code Query or Rule Body
No methods matched
![]() | Methods directly and indirectly called by test Methods |
// Lists all methods called directly or indirectly by tests methods.
// Overrides of virtual and absract methods, called through polymorphism, are not listed.
// Methods solely invoked through a delegate are not listed.
// Methods solely invoked through reflection are not listed.
// We advise to not include test assemblies in code analyzed by NDepend.
// But if you wish the current query to run properly,
// you'll need to consider test assemblies in your list of application assemblies analyzed by NDepend.
let testAttr = from t in ThirdParty.Types.WithNameIn("TestAttribute", "TestCaseAttribute") select t
let testMethods = Methods.TaggedWithAnyAttributes(testAttr)
// --- Uncomment this line if your test methods are in dedicated test assemblies ---
// let testAssemblies = testMethods.ParentAssemblies().ToHashSet()
let depthOfCalledByTest = Application.Methods.DepthOfIsUsedByAny(testMethods)
from pair in depthOfCalledByTest
where pair.Value > 0
orderby pair.Value ascending
// --- Uncomment this line if your test methods are in dedicated test assemblies ---
//&& !testAssemblies.Contains(pair.CodeElement.ParentAssembly)
select new {
method = pair.CodeElement,
// (depthOfCalledByTests == 1) means that the method is directly called by tests
// (depthOfCalledByTests == 2) means that the method is directly called by a method directly called by tests
// ...
depthOfCalledByTests = pair.Value,
// --- Uncomment this line if your project import some coverage data ---
// m.PercentageCoverage
}View Code Query or Rule Body
No methods matched
Dead Code
![]() | Potentially dead Types |
warnif count > 0
// Filter procedure for types that should'nt be considered as dead
let canTypeBeConsideredAsDeadProc = new Func<IType, bool>(
t => !t.IsPublic && // Public types might be used by client applications of your assemblies.
t.Name != "Program" &&
!t.IsGeneratedByCompiler &&
// If you don't want to link NDepend.API.dll, you can use your own IsNotDeadCodeAttribute and adapt this rule.
!t.HasAttribute("NDepend.Attributes.IsNotDeadCodeAttribute".AllowNoMatch()) &&
// Exclude static types that define only const fields
// because they cannot be seen as used in IL code.
!(t.IsStatic && t.NbMethods == 0 && !t.Fields.Where(f => !f.IsLiteral).Any()))
// Select types unused
let typesUnused =
from t in JustMyCode.Types where
t.NbTypesUsingMe == 0 && canTypeBeConsideredAsDeadProc(t)
select t
// Dead types = types used only by unused types (recursive)
let deadTypesMetric = typesUnused.FillIterative(
types => from t in codeBase.Application.Types.UsedByAny(types).Except(types)
where canTypeBeConsideredAsDeadProc(t) &&
t.TypesUsingMe.Intersect(types).Count() == t.NbTypesUsingMe
select t)
from t in deadTypesMetric.DefinitionDomain
select new { t, t.TypesUsingMe, depth = deadTypesMetric[t] }View Code Query or Rule Body
No types matched
![]() | Critical Rule warning: Potentially dead Methods |
warnif count > 0
// Filter procedure for methods that should'nt be considered as dead
let canMethodBeConsideredAsDeadProc = new Func<IMethod, bool>(
m => !m.IsPubliclyVisible && // Public methods might be used by client applications of your assemblies.
!m.IsEntryPoint && // Main() method is not used by-design.
!m.IsExplicitInterfaceImpl && // The IL code never explicitely calls explicit interface methods implementation.
!m.IsClassConstructor && // The IL code never explicitely calls class constructors.
!m.IsFinalizer && // The IL code never explicitely calls finalizers.
!m.IsVirtual && // Only check for non virtual method that are not seen as used in IL.
!(m.IsConstructor && // Don't take account of protected ctor that might be call by a derived ctors.
m.IsProtected) &&
!m.IsEventAdder && // The IL code never explicitely calls events adder/remover.
!m.IsEventRemover &&
!m.IsGeneratedByCompiler &&
!m.ParentType.IsDelegate &&
// Methods tagged with these two attributes are called by the serialization infrastructure.
!m.HasAttribute("System.Runtime.Serialization.OnSerializingAttribute".AllowNoMatch()) &&
!m.HasAttribute("System.Runtime.Serialization.OnDeserializedAttribute".AllowNoMatch()) &&
// If you don't want to link NDepend.API.dll, you can use your own IsNotDeadCodeAttribute and adapt this rule.
!m.HasAttribute("NDepend.Attributes.IsNotDeadCodeAttribute".AllowNoMatch()))
// Get methods unused
let methodsUnused =
from m in JustMyCode.Methods where
m.NbMethodsCallingMe == 0 &&
canMethodBeConsideredAsDeadProc(m)
select m
// Dead methods = methods used only by unused methods (recursive)
let deadMethodsMetric = methodsUnused.FillIterative(
methods => // Unique loop, just to let a chance to build the hashset.
from o in (new object()).ToEnumerable()
// Use a hashet to make Intersect calls much faster!
let hashset = methods.ToHashSet()
from m in codeBase.Application.Methods.UsedByAny(methods).Except(methods)
where canMethodBeConsideredAsDeadProc(m) &&
// Select methods called only by methods already considered as dead
hashset.Intersect(m.MethodsCallingMe).Count() == m.NbMethodsCallingMe
select m)
from m in JustMyCode.Methods.Intersect(deadMethodsMetric.DefinitionDomain)
select new { m, m.MethodsCallingMe, depth = deadMethodsMetric[m] }View Code Query or Rule Body
1 methods matched
method | MethodsCallingMe | depth | Full Name |
---|---|---|---|
.ctor() | 0 method | 0 | ColorMine.ColorSpaces.Conversions .CmykProfileConverter..ctor() |
Statistics
Stat | MethodsCallingMe | depth |
---|---|---|
Sum: | 0 | 0 |
Average: | 0 | 0 |
Minimum: | 0 | 0 |
Maximum: | 0 | 0 |
Standard deviation: | 0 | 0 |
Variance: | 0 | 0 |
![]() | Critical Rule warning: Potentially dead Fields |
warnif count > 0
from f in JustMyCode.Fields where
f.NbMethodsUsingMe == 0 &&
!f.IsPublic && // Although not recommended, public fields might be used by client applications of your assemblies.
!f.IsLiteral && // The IL code never explicitely uses literal fields.
!f.IsEnumValue && // The IL code never explicitely uses enumeration value.
f.Name != "value__" && // Field named 'value__' are relative to enumerations and the IL code never explicitely uses them.
!f.HasAttribute("NDepend.Attributes.IsNotDeadCodeAttribute".AllowNoMatch()) &&
!f.IsGeneratedByCompiler
// If you don't want to link NDepend.API.dll, you can use your own IsNotDeadCodeAttribute and adapt this rule.
select fView Code Query or Rule Body
1 fields matched
field | Full Name |
---|---|
pad | ColorMine.ColorSpaces.Conversions .CmykProfileConverter+RgbColor.pad |
Statistics
Stat |
---|
Sum: |
Average: |
Minimum: |
Maximum: |
Standard deviation: |
Variance: |
![]() | Wrong usage of IsNotDeadCodeAttribute |
// This IsNotDeadCodeAttribute can be used to signify that
// despite a member could be removed without provoking any syntax error
// (we also say it is dead code), your intention is to not remove this member.
// Default 'Dead Code' code rules take account of this attribute.
// IsNotDeadCodeAttribute is defined in NDepend.API.dll
// If you don't want to link NDepend.API.dll, you can use
// your own IsNotDeadCodeAttribute and adapt this rule.
warnif count == 1
let tAttr = Types.WithFullName("NDepend.Attributes.IsNotDeadCodeAttribute").FirstOrDefault()
where tAttr != null
// Get types that do a wrong usage of IsNotDeadCodeAttribute
let types = from t in Application.Types where
t.HasAttribute("NDepend.Attributes.IsNotDeadCodeAttribute".AllowNoMatch()) &&
( // types used don't need to be tagged with IsNotDeadCodeAttribute!
t.NbTypesUsingMe > 0 ||
// Static types that define only const fields cannot be seen as used in IL code.
// They don't need to be tagged with IsNotDeadCodeAttribute.
(t.IsStatic && t.NbMethods == 0 && !t.Fields.Where(f => !f.IsLiteral).Any())
)
select t
// Get methods that do a wrong usage of IsNotDeadCodeAttribute
let methods = from m in Application.Methods where
m.HasAttribute("NDepend.Attributes.IsNotDeadCodeAttribute".AllowNoMatch()) &&
m.NbMethodsCallingMe > 0
select m
// Get fields that do a wrong usage of IsNotDeadCodeAttribute
let fields = from f in Application.Fields where
f.HasAttribute("NDepend.Attributes.IsNotDeadCodeAttribute".AllowNoMatch()) &&
f.NbMethodsUsingMe > 0
select f
where types.Count() > 0 || methods.Count() > 0 || fields.Count() > 0
select new { tAttr, types , methods, fields }View Code Query or Rule Body
No types matched
Trend Charts
Lines of Code
Rules Violated
Rules Violations
Percentage Coverage by Tests

Max
Average
Third-Party Usage
Assemblies Dependencies
Assembly | Depends on | Is referenced by |
---|---|---|
ColorMine v1.0.0.0 | mscorlib v4.0.0.0 ; System v4.0.0.0 ; PresentationCore v4.0.0.0 ; System.Drawing v4.0.0.0 ; | ColorMine.Test v1.0.0.0 ; |
ColorMine.Test v1.0.0.0 | mscorlib v4.0.0.0 ; ColorMine v1.0.0.0 ; | - |
Assemblies Build Order
- ColorMine
- ColorMine.Test
Assemblies Build Order
- ColorMine
- ColorMine.Test
Analysis Log : Information and Warnings
The Warnings can reveal potential flaws concerning the health of the build process.
A particular warn can be disabled through the NDepend interactive UI, panel Error List, tick the checkbox Disabled corresponding to the warn to disable.
Message | |
---|---|
![]() | Begin full analysis with NDepend v5.2.1.8320 |
![]() | No Baseline for Comparison loaded. |
![]() | Can't load the assembly {Microsoft.VisualStudio.QualityTools.UnitTestFramework}: Can't find the .NET assembly {Microsoft.VisualStudio.QualityTools.UnitTestFramework} in specified folders. Has it been compiled properly? Is the NDepend project missing the containing folder of the .NET assembly? |
![]() | Concurrent mode |
![]() | .NET Assembly loaded from {C:\projects\ColorMine\ColorMine\bin\Debug} ColorMine.dll v1.0.0.0 |
![]() | .NET Assembly loaded from {C:\projects\ColorMine\ColorMine.Test\bin\Debug} ColorMine.Test.dll v1.0.0.0 |
![]() | .NET Assemblies loaded from {C:\Windows\Microsoft.NET\Framework\v4.0.30319} mscorlib.dll v4.0.0.0 System.dll v4.0.0.0 System.Drawing.dll v4.0.0.0 |
![]() | .NET Assembly loaded from {C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF} PresentationCore.dll v4.0.0.0 |
![]() | Assembly {Microsoft.VisualStudio.QualityTools.UnitTestFramework} is referenced by {ColorMine.Test} but is not found. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine\ColorSpaces\ColorSpace.cs} (last modified 5/10/2014 2:30:45 PM) and the PDB file of the assembly {ColorMine} (last modified 4/15/2014 8:22:20 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine\ColorSpaces\ColorSpaces.cs} (last modified 5/10/2014 9:55:25 PM) and the PDB file of the assembly {ColorMine} (last modified 4/15/2014 8:22:20 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine\ColorSpaces\Conversions\HsbConverter.cs} (last modified 5/2/2014 8:45:34 PM) and the PDB file of the assembly {ColorMine} (last modified 4/15/2014 8:22:20 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine\ColorSpaces\Conversions\Utility\DoubleExtension.cs} (last modified 5/2/2014 8:17:39 PM) and the PDB file of the assembly {ColorMine} (last modified 4/15/2014 8:22:20 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine\Sets\KMeansClusteringCounter.cs} (last modified 5/10/2014 9:57:09 PM) and the PDB file of the assembly {ColorMine} (last modified 4/15/2014 8:22:20 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine\Sets\SingleColorPaletteColorCounter.cs} (last modified 5/10/2014 9:57:09 PM) and the PDB file of the assembly {ColorMine} (last modified 4/15/2014 8:22:20 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine\Properties\AssemblyInfo.cs} (last modified 5/2/2014 8:45:34 PM) and the PDB file of the assembly {ColorMine} (last modified 4/15/2014 8:22:20 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine\Sets\AllColorCounter.cs} (last modified 5/10/2014 9:57:09 PM) and the PDB file of the assembly {ColorMine} (last modified 4/15/2014 8:22:20 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine\Sets\IColorCounter.cs} (last modified 5/10/2014 9:42:46 PM) and the PDB file of the assembly {ColorMine} (last modified 4/15/2014 8:22:20 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine\Sets\IColorMatrix.cs} (last modified 5/10/2014 9:51:05 PM) and the PDB file of the assembly {ColorMine} (last modified 4/15/2014 8:22:20 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine\Sets\ColorCounter.cs} (last modified 5/10/2014 9:42:46 PM) and the PDB file of the assembly {ColorMine} (last modified 4/15/2014 8:22:20 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine.Test\ColorSpaces\ConversionTests.cs} (last modified 5/2/2014 8:45:34 PM) and the PDB file of the assembly {ColorMine.Test} (last modified 4/15/2014 8:22:22 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine.Test\ColorSpaces\Comparisons\Cie1976ComparisonTest.cs} (last modified 5/2/2014 8:17:39 PM) and the PDB file of the assembly {ColorMine.Test} (last modified 4/15/2014 8:22:22 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine.Test\Sets\AllCounterCounterTest.cs} (last modified 5/10/2014 9:42:56 PM) and the PDB file of the assembly {ColorMine.Test} (last modified 4/15/2014 8:22:22 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine.Test\Sets\ColorCounterTest.cs} (last modified 5/10/2014 9:42:56 PM) and the PDB file of the assembly {ColorMine.Test} (last modified 4/15/2014 8:22:22 PM) are not in-sync. |
![]() | The source file {\\psf\dropbox\projects\ColorMine\ColorMine.Test\Sets\KMeansClusteringCounterTest.cs} (last modified 5/10/2014 9:51:03 PM) and the PDB file of the assembly {ColorMine.Test} (last modified 4/15/2014 8:22:22 PM) are not in-sync. |
![]() | 40 source files parsed ; all source files found ; 16 source files not in-sync with PDB |
![]() | 0 code rule has been extracted from code. |
![]() | No dependency cycle detected in assemblies referencement graph. |
![]() | 07/25/2014 21:20:37 Analyse dependencies of your application. |
![]() | 07/25/2014 21:20:38 Log trend metrics values. |
![]() | 07/25/2014 21:20:38 Execute queries and rules |
![]() | 3 critical rules are violated. - Avoid namespaces mutually dependent - Potentially dead Methods - Potentially dead Fields |
![]() | 07/25/2014 21:20:39 NDepend analysis done. Duration: 00:02 |
![]() | 07/25/2014 21:20:39 Building the report (standard). |