Skip to content

Commit

Permalink
added dispersed, intensive coupling, existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Barkowsky committed Jul 11, 2014
1 parent e97b38f commit 06c2dbe
Show file tree
Hide file tree
Showing 419 changed files with 2,297 additions and 94 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
displaying
formatAsMethodList

self valueFormatRule: [:v | | value |
value := ''.
v allButLastDo: [:each | value := value, each name, ', '].
value := value, v last name.
value].
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
itemsSelect: aBlock

^ self items select: aBlock
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"newWith:collect:" : "AT 5/7/2008 21:30",
"newWith:select:" : "AT 5/7/2008 21:30" },
"instance" : {
"formatAsMethodList" : "MB 7/10/2014 13:48",
"itemCount" : "AT 5/7/2008 21:30",
"items" : "AT 5/7/2008 21:30",
"itemsCollect:" : "MT 5/23/2014 16:52",
"itemsDo:" : "AT 5/7/2008 21:30",
"itemsReject:" : "MB 6/14/2014 19:50",
"itemsSelect:" : "MB 7/10/2014 13:49",
"showOnlyIfNotEmpty" : "MB 6/24/2014 12:09" } }
2 changes: 1 addition & 1 deletion packages/SwaLint-Core.package/monticello.meta/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7d316aa1-5901-43fe-9b64-081b8492d1d2
8ce4eba9-5551-0944-8b43-cab41086e16d
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(name 'SwaLint-Core-MB.35'message 'added formatting method for method lists'id '8ce4eba9-5551-0944-8b43-cab41086e16d'date '10 July 2014'time '1:50:14.935 pm'author 'MB'ancestors ((id '7d316aa1-5901-43fe-9b64-081b8492d1d2'))stepChildren ())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ offeredTestsData
{#tightClassCohesion. 'Tight Class Cohesion [TCC]'. 'Number of methodpairs that access similar instance variables .'}.
{#newlyAddedServicesRatio. 'Percentage of Newly Added Services [PNAS]'. 'Answer the number of methods of a class that are not overridden or specialized from the ancestors, divided by the total number of methods.'}.
{#weightOfClass. 'Weight of Class [WOC]'. 'The number of "functional" methods divided by the total number of members.'}.
{#classAMW. 'AMW of a class [AWM]'. 'Average Method Weight'}.
{#classNAS. 'NAS of a class [NAS]'. 'Number of added Services'}.
{#classPNAS. 'PNAS of a class [PNAS]'. 'Percentage of newly added Services'}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests
classAMW: aSLClassTestObject

| amw methodNumber totalWeight |

methodNumber := (aSLClassTestObject resultOf: #numberOfMethods) result.
totalWeight := (aSLClassTestObject resultOf: #weightedMethodCount) result.
amw := (methodNumber = 0) ifTrue: [0]
ifFalse: [totalWeight / methodNumber].

^ self numericResult: amw withThresholdFor: #ClassAMW
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests
classNAS: aSLClassTestObject

| publicMethods nonOverridingMethods addedServices |

publicMethods := aSLClassTestObject resultOf: #allPublicMethods.
nonOverridingMethods := self nonOverridingMethodsOf: aSLClassTestObject.
addedServices := publicMethods itemsSelect:
[:each | nonOverridingMethods includes: each].

^ self integerResult: addedServices size withThresholdFor: #NumberOfMethods
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests
classPNAS: aSLClassTestObject

| publicMethods nas |

publicMethods := aSLClassTestObject resultOf: #allPublicMethods.
nas := aSLClassTestObject resultOf: #classNAS.

^ self percentageResult: ((publicMethods itemCount = 0)
ifTrue: [0]
ifFalse: [nas / publicMethods itemCount])
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
private
nonOverridingMethodsOf: aSLClassTestObject

| selectors nonOverridingMethods |

selectors := aSLClassTestObject methods collect: [ :each | each methodSelector].
nonOverridingMethods := selectors reject:
[ :each | aSLClassTestObject testObject superclass allSelectors includes: each].

^ nonOverridingMethods collect: [:each | aSLClassTestObject methodForSelector: each]
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,24 @@
"WMCSTDEV" : "SO 7/9/2014 18:01",
"WMCSTDEV:" : "SO 7/9/2014 18:02",
"defaultCategory" : "SO 7/9/2014 18:01",
"offeredTestsData" : "AT 5/7/2008 21:29" },
"offeredTestsData" : "MB 7/10/2014 10:14" },
"instance" : {
"accessToForeignData:" : "AT 5/7/2008 21:33",
"allForeignMethodsUsedIn:" : "AT 5/7/2008 21:33",
"allMethodsUsedIn:" : "AT 5/7/2008 21:33",
"avgLOCperMethod:" : "AT 5/17/2008 11:36",
"baseClassOverridingRatio:" : "AT 5/7/2008 21:33",
"classAMW:" : "MB 7/10/2014 10:14",
"classLOC:" : "AT 5/7/2008 21:33",
"classNAS:" : "MB 7/10/2014 10:15",
"classPNAS:" : "MB 7/10/2014 10:15",
"cohesion:" : "AT 5/7/2008 21:33",
"computeHITRecursively:" : "AT 5/7/2008 21:33",
"heightOfInheritanceTree:" : "AT 5/7/2008 21:33",
"method:appearsIn:" : "AT 5/7/2008 21:33",
"method:isAccessorAndAppearsIn:" : "AT 5/7/2008 21:33",
"newlyAddedServicesRatio:" : "AT 5/7/2008 21:32",
"nonOverridingMethodsOf:" : "MB 7/10/2014 10:15",
"numberOfAccessorMethods:" : "topa 4/22/2010 17:18",
"numberOfAddedServices:" : "AT 5/17/2008 11:38",
"numberOfClassMethods:" : "AT 5/7/2008 21:32",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ differingLineEndings: aSLClassTestObject
aSLClassTestObject shouldBeClass.
^ self summarizeNumberOf: aSLClassTestObject methods
withResultOf: #csMethodLineEnding
satisfying: [ :result | (result = 1) not ].
satisfying: [ :result | (result = 1) not ]
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"countDotsAfterReturn:" : "AT 5/22/2008 15:19",
"csMethodHasDotAfterReturn:" : "SO 7/9/2014 19:08",
"csMethodLineEnding:" : "MB 6/19/2014 10:28",
"differingLineEndings:" : "MB 6/19/2014 10:40",
"differingLineEndings:" : "MB 7/10/2014 10:15",
"dotAfterReturn:" : "AT 5/22/2008 15:18",
"endOfBlockOrArray:startingAt:" : "AT 5/7/2008 21:30",
"endOfCommand:startingAt:" : "AT 5/8/2008 09:47",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ShortMemoryCap
<slpreference:'Short memory cap'
type: #Numeric
categories: #(Disharmony)
defaultValue: 3
defaultValue: 30
helpText: 'The number of items, that can be memorized by the short-term memory.'>

^ ShortMemoryCap ifNil: [3].
^ ShortMemoryCap ifNil: [30].
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ offeredTestsData
{#shotgunSurgery. 'Shotgun Surgery'. 'Evaluates wether there are Shotgun Surgeries'}.
{#significantDuplication. 'Significant Duplication'. 'Evaluates wether there are Significant Duplications'}.
{#featureEnvy. 'Feature Envy'. 'Evaluates wether there is Feature Envy'}.
"{#intenseCoupling. 'Intense Coupling'. ''}."
{#intensiveCoupling. 'Intensive Coupling'. 'Evaluates wether there is Intensive Coupling'}.
{#dispersedCoupling. 'Dispersed Coupling'. 'Evaluates wether there is Dispersed Coupling'}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tests
dispersedCoupling: aSLMethodTestObject

aSLMethodTestObject ifClassTestChildrenWith: #dispersedCoupling.
aSLMethodTestObject shouldBeMethod.
^ self successResult:
((self looksLikeDispersedCoupling: aSLMethodTestObject) and:
[(aSLMethodTestObject resultOf: #maxNesting) > #one])
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tests
intensiveCoupling: aSLMethodTestObject

aSLMethodTestObject ifClassTestChildrenWith: #intensiveCoupling.
aSLMethodTestObject shouldBeMethod.
^ self successResult:
((self looksLikeIntensiveCoupling: aSLMethodTestObject) and:
[(aSLMethodTestObject resultOf: #maxNesting) > #one])
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
private
looksLikeDispersedCoupling: aSLMethodTestObject

^ (((aSLMethodTestObject resultOf: #methodCINT)
> (SLPreferences preferenceAt: #ShortMemoryCap) preferenceValue) and:
[(aSLMethodTestObject resultOf: #methodCDISP) >= 0.5])
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
private
looksLikeIntensiveCoupling: aSLMethodTestObject

^ ((((aSLMethodTestObject resultOf: #methodCINT)
> (SLPreferences preferenceAt: #ShortMemoryCap) preferenceValue) and:
[(aSLMethodTestObject resultOf: #methodCDISP) < 0.5]) or:
[(((aSLMethodTestObject resultOf: #methodCINT) > #few) and:
[(aSLMethodTestObject resultOf: #methodCDISP) < 0.25])])
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,30 @@
"MinimumDuplicationChainLength:" : "SO 7/9/2014 17:57",
"MinimumExactCloneSize" : "SO 7/9/2014 17:57",
"MinimumExactCloneSize:" : "SO 7/9/2014 17:57",
"ShortMemoryCap" : "SO 7/9/2014 18:10",
"ShortMemoryCap" : "MB 7/10/2014 12:58",
"ShortMemoryCap:" : "SO 7/9/2014 17:57",
"SignificantStandaloneExactCloneSize" : "SO 7/9/2014 17:57",
"SignificantStandaloneExactCloneSize:" : "SO 7/9/2014 17:57",
"SmallLineBias" : "SO 7/9/2014 17:57",
"SmallLineBias:" : "SO 7/9/2014 17:58",
"defaultCategory" : "AT 5/8/2008 09:28",
"offeredTestsData" : "MB 6/14/2014 20:04" },
"offeredTestsData" : "MB 7/10/2014 10:16" },
"instance" : {
"brainClass:" : "MB 6/17/2014 12:59",
"brainMethod:" : "AT 5/27/2008 00:48",
"dataClass:" : "AT 5/27/2008 19:19",
"dispersedCoupling:" : "MB 7/10/2014 13:28",
"featureEnvy:" : "MB 6/19/2014 08:20",
"godClass:" : "topa 12/7/2012 14:18",
"intensiveCoupling:" : "MB 7/10/2014 10:17",
"isExcessivelyLarge:" : "SO 7/9/2014 19:06",
"lineIn:at:equals:at:" : "MB 6/17/2014 13:02",
"loadPreferences" : "HD 7/9/2014 19:36",
"looksLikeBrainClass:" : "SO 7/9/2014 19:11",
"looksLikeBrainMethod:" : "AT 5/27/2008 00:48",
"looksLikeDataClass:" : "AT 5/8/2008 09:28",
"looksLikeDispersedCoupling:" : "MB 7/10/2014 12:53",
"looksLikeIntensiveCoupling:" : "MB 7/10/2014 12:55",
"searchCloneIn:from:comparedWith:from:range:" : "SO 7/9/2014 19:01",
"shotgunSurgery:" : "SO 7/9/2014 19:02",
"significantDuplication:" : "MB 6/17/2014 13:00",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ offeredTestsData
{#methodLAA. 'Locality of Attribute Accesses [LAA]'}.
{#methodFDP. 'Foreign Data Providers [FDP]'}.
{#methodATFD. 'Access To Foreign Data [ATFD]'}.
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ tests
methodCINT: aSLMethodTestObject
"Answer the number of distinct message selectors sent by a method"

^ self integerResult:
^ self fewManyResult:
(aSLMethodTestObject resultOf: #calledOperations) itemCount

Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ tests
numberOfAccessedVars: aSLMethodTestObject

^ self fewManyResult:
(aSLMethodTestObject resultOf: #usedInstVars) itemCount
(aSLMethodTestObject resultOf: #usedVars) itemCount
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
"ShowMethodMetricTests:" : "SO 7/9/2014 17:56",
"defaultCategory" : "SO 7/9/2014 17:56",
"ifAndSimilar" : "AT 5/8/2008 09:41",
"offeredTestsData" : "MB 6/19/2014 11:10" },
"offeredTestsData" : "MB 7/10/2014 10:26" },
"instance" : {
"isAddedService:" : "AT 5/8/2008 09:35",
"maxNesting:" : "AT 5/27/2008 00:42",
"methodATFD:" : "MB 6/19/2014 10:00",
"methodCC:" : "MB 6/19/2014 10:01",
"methodCDISP:" : "AT 5/27/2008 14:54",
"methodCINT:" : "AT 5/27/2008 14:29",
"methodCINT:" : "MB 7/10/2014 10:21",
"methodCM:" : "MB 6/19/2014 10:01",
"methodCYCLO:" : "AT 5/28/2008 12:24",
"methodFDP:" : "MB 6/19/2014 10:01",
"methodLAA:" : "MB 6/19/2014 10:01",
"methodLOC:" : "AT 5/28/2008 12:24",
"noavPerCint:" : "AT 5/27/2008 14:55",
"nodeCYCLO:" : "AT 5/8/2008 09:36",
"numberOfAccessedVars:" : "AT 5/28/2008 12:07",
"numberOfAccessedVars:" : "MB 7/10/2014 12:56",
"test:with:" : "AT 5/17/2008 17:05" } }
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ offeredTestsData
"for methods"
{#isGetter. nil. 'Method only returns a variable'}.
{#isSetter. nil. 'Method only sets a variable'}.
{#isPrivate. nil. 'Method is private'}.
{#isAccessor. nil. 'Method ist getter or setter.'}.
{#accessedVar. nil. 'Name of the accessed variable, for accessors only'}.
{#usedInstVars. nil. 'Collection of all inst vars used by a method'}.
Expand All @@ -13,8 +14,10 @@ offeredTestsData
{#methodWidth. nil. 'Maximum number of characters in the lines of a method'}.
{#calledOperations. nil. ''}.
{#methodCallers. nil. 'Collection of all callers of a method'}.
{#overrides. nil. 'Method overrides a method from superclass'}.
"for classes"
{#allAccessors. nil. 'Collection of all accessors of a class'}.
{#allPublicMethods. nil. 'Collection of all public methods of a class'}.
{#classWidth. nil. 'Maximum method width'}.
"{#miscTest. 'Misc-Plugin Dummy Test'. nil. 'Misc Tests'}."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class tests
allPublicMethods: aSLClassTestObject

aSLClassTestObject shouldBeClass.

^ SLCollectionResult
newWith: aSLClassTestObject methods
select: [ :method | (method resultOf: #isPrivate) isNegative]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
method tests
isPrivate: aSLMethodTestObject

aSLMethodTestObject shouldBeMethod.
^ self booleanResult:
(self methodIsPrivate: aSLMethodTestObject testObject)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class tests
method tests
methodCallers: aSLMethodTestObject

| methods |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
private
methodIsPrivate: aCompiledMethod

| category selector |

selector := aCompiledMethod selector.
category := aCompiledMethod methodClass categoryForSelector: selector.

^ (selector beginsWith: '_') or: [category includesSubString: 'private']
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"class" : {
"defaultCategory" : "AT 5/8/2008 09:40",
"offeredTestsData" : "MB 6/19/2014 11:12" },
"offeredTestsData" : "MB 7/10/2014 10:24" },
"instance" : {
"accessedVar:" : "AT 5/8/2008 09:37",
"allAccessors:" : "AT 5/27/2008 17:29",
"allPublicMethods:" : "MB 7/10/2014 10:24",
"calledOperations:" : "AT 5/27/2008 14:06",
"classWidth:" : "AT 5/8/2008 09:37",
"collectAllVarsOf:" : "MB 6/17/2014 12:58",
Expand All @@ -15,9 +16,11 @@
"indirectlyAccessedVars:in:" : "MB 6/14/2014 16:10",
"isAccessor:" : "MB 6/12/2014 09:55",
"isGetter:" : "AT 5/8/2008 09:38",
"isPrivate:" : "MB 7/10/2014 10:25",
"isSetter:" : "AT 5/8/2008 09:38",
"methodCallers:" : "MB 6/19/2014 11:11",
"methodIsGetter:" : "AT 5/8/2008 09:38",
"methodIsPrivate:" : "MB 7/10/2014 10:26",
"methodIsSetter:" : "topa 10/24/2012 11:48",
"methodWidth:" : "AT 5/8/2008 09:38",
"miscTest:" : "AT 5/8/2008 09:38",
Expand Down
2 changes: 1 addition & 1 deletion packages/SwaLint-PlugIns.package/monticello.meta/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bfae734c-4059-4e5a-817a-eb78d5804e2d
1d27705d-84fb-4b42-b27b-87426b46bd90
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(name 'SwaLint-PlugIns-MB.36'message 'empty log message'id 'a359d6ae-fe50-ab42-b879-e97acad59a0f'date '10 July 2014'time '1:30:40.492 pm'author 'MB'ancestors ((id 'bfae734c-4059-4e5a-817a-eb78d5804e2d'))stepChildren ())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(name 'SwaLint-PlugIns-MB.37'message 'added dispersed and intensive coupling'id '1d27705d-84fb-4b42-b27b-87426b46bd90'date '10 July 2014'time '1:53:17.314 pm'author 'MB'ancestors ((id 'a359d6ae-fe50-ab42-b879-e97acad59a0f'))stepChildren ())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
bar: anObject

bar := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
bar

^ bar
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
foo: anObject

foo := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
foo

^ foo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
accessing
foobar: anObject
Loading

0 comments on commit 06c2dbe

Please sign in to comment.