Skip to content

Commit

Permalink
Merge pull request #16 from moosetechnology/main
Browse files Browse the repository at this point in the history
rebase develop from main
  • Loading branch information
alkalinan authored Jul 31, 2024
2 parents 120ab31 + 48c9c9c commit a16cca3
Show file tree
Hide file tree
Showing 26 changed files with 378 additions and 123 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# GitProject health

[![CI Moose 11](https://github.com/moosetechnology/GitProjectHealth/actions/workflows/ci-moose11.yml/badge.svg)](https://github.com/moosetechnology/GitProjectHealth/actions/workflows/ci-moose11.yml)
[![Coverage Status](https://coveralls.io/repos/github/moosetechnology/GitProjectHealth/badge.svg?branch=main)](https://coveralls.io/github/moosetechnology/GitProjectHealth?branch=main)


This project includes a model, an importer, and some visulization to evaluate the health of a GitLab or GitHub group.

## Installation
Expand Down
19 changes: 11 additions & 8 deletions src/BaselineOfGitLabHealth/BaselineOfGitLabHealth.class.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Class {
#name : #BaselineOfGitLabHealth,
#superclass : #BaselineOf,
#category : #BaselineOfGitLabHealth
#name : 'BaselineOfGitLabHealth',
#superclass : 'BaselineOf',
#category : 'BaselineOfGitLabHealth',
#package : 'BaselineOfGitLabHealth'
}

{ #category : #baselines }
{ #category : 'baselines' }
BaselineOfGitLabHealth >> baseline: spec [

<baseline>
Expand All @@ -21,14 +22,14 @@ BaselineOfGitLabHealth >> baseline: spec [
spec package: 'GitLabHealth-Model' with: [ spec requires: #( 'Moose' ) ] ] ]
]

{ #category : #baselines }
{ #category : 'baselines' }
BaselineOfGitLabHealth >> customProjectAttributes [
self class environment at: #MooseEntity ifAbsent: [ ^ #(#WithoutFamix) ].

^ #()
]

{ #category : #baselines }
{ #category : 'baselines' }
BaselineOfGitLabHealth >> defineDependencies: spec [

spec
Expand All @@ -39,11 +40,11 @@ BaselineOfGitLabHealth >> defineDependencies: spec [
with: [ spec repository: 'github://badetitou/MoreLogger:main/src' ]
]

{ #category : #baselines }
{ #category : 'baselines' }
BaselineOfGitLabHealth >> defineGroups: spec [
]

{ #category : #baselines }
{ #category : 'baselines' }
BaselineOfGitLabHealth >> definePackages: spec [

spec
Expand Down Expand Up @@ -72,6 +73,8 @@ BaselineOfGitLabHealth >> definePackages: spec [
package: 'GLPHExtended-Model' with: [
spec requires:
#( 'GitLabHealth-Model' 'GitLabHealth-Model-Extension' ) ];
package: 'GLPHExtended-Model-Tests'
with: [ spec requires: #( 'GLPHExtended-Model' ) ];
package: 'GLPHExtended-Model-Extension' with: [
spec requires:
#( 'GLPHExtended-Model' 'GitLabHealth-Model' 'GitLabHealth-Model-Extension' ) ];
Expand Down
2 changes: 1 addition & 1 deletion src/BaselineOfGitLabHealth/package.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Package { #name : #BaselineOfGitLabHealth }
Package { #name : 'BaselineOfGitLabHealth' }
23 changes: 13 additions & 10 deletions src/GLPHExtended-Model-Extension/GLPHEChange.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,20 @@ GLPHEChange >> name [
GLPHEChange class >> newFrom: aDiffLine [
"Factory a Change from a loc"

| aChange code|
aChange := GLPHELineOfCode new.

| aChange trimedLine code |
trimedLine := aDiffLine trim.

aChange := (trimedLine beginsWith: #+)
ifTrue: [ GLPHEAddition new ]
ifFalse: [
(aDiffLine trim beginsWith: #-)
ifTrue: [ GLPHEDeletion new ]
ifFalse: [ GLPHELineOfCode new ] ].

code := aDiffLine.
(aDiffLine beginsWith: #'@@') ifTrue: [
code := (aDiffLine splitOn: '@@') copyWithoutFirst second.
].
(aDiffLine trim beginsWith: #+) ifTrue: [ aChange := GLPHEAddition new. ].
(aDiffLine trim beginsWith: #-) ifTrue: [ aChange := GLPHEDeletion new. ].

(trimedLine beginsWith: #'@@') ifTrue: [
code := (trimedLine splitOn: '@@') copyWithoutFirst second ].
aChange sourceCode: code.

^ aChange
]
15 changes: 8 additions & 7 deletions src/GLPHExtended-Model-Extension/GLPHEDiffRange.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ GLPHEDiffRange >> name [

{ #category : #'*GLPHExtended-Model-Extension' }
GLPHEDiffRange class >> newFrom: aLine [
|range infos rangesInfo |
range := GLPHEDiffRange new.
infos := (aLine splitOn: '@@') copyWithoutFirst.
rangesInfo := infos first trim splitOn: ' '.

| range infos rangesInfo |
range := GLPHEDiffRange new.
infos := (aLine splitOn: '@@') second.
rangesInfo := infos trim splitOn: ' '.
range originalLineRange: rangesInfo first.
range newLineRange: rangesInfo second .
^ range.
range newLineRange: rangesInfo second.

^ range
]
35 changes: 35 additions & 0 deletions src/GLPHExtended-Model-Tests/GLPHEChangeTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"
A GLPHEChangeTest is a test class for testing the behavior of GLPHEChange
"
Class {
#name : #GLPHEChangeTest,
#superclass : #TestCase,
#category : #'GLPHExtended-Model-Tests-Entities'
}

{ #category : #tests }
GLPHEChangeTest >> testNewEntityFromString [

| change |
change := GLPHEChange newFrom: '+ helloWorld'.
self assert: change class equals: GLPHEAddition.
self assert: change sourceCode equals: '+ helloWorld'
]

{ #category : #tests }
GLPHEChangeTest >> testNewEntityFromStringDeletion [

| change |
change := GLPHEChange newFrom: '- helloWorld'.
self assert: change class equals: GLPHEDeletion.
self assert: change sourceCode equals: '- helloWorld'
]

{ #category : #tests }
GLPHEChangeTest >> testNewEntityFromStringLOC [

| change |
change := GLPHEChange newFrom: 'helloWorld'.
self assert: change class equals: GLPHELineOfCode.
self assert: change sourceCode equals: 'helloWorld'
]
28 changes: 28 additions & 0 deletions src/GLPHExtended-Model-Tests/GLPHEDiffRangeTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"
A GLPHEDiffRangeTest is a test class for testing the behavior of GLPHEDiffRange
"
Class {
#name : #GLPHEDiffRangeTest,
#superclass : #TestCase,
#category : 'GLPHExtended-Model-Tests-Entities'
}

{ #category : #tests }
GLPHEDiffRangeTest >> testNewEntityFromString [

| diffRange |
diffRange := GLPHEDiffRange newFrom:
'@@ -15,9 +15,9 @@ LLMModifierTest >> testGetViolationsMessage ['.
self assert: diffRange originalLineRange equals: '-15,9'.
self assert: diffRange newLineRange equals: '+15,9'
]

{ #category : #tests }
GLPHEDiffRangeTest >> testNewEntityFromStringWithDifferentValues [

| diffRange |
diffRange := GLPHEDiffRange newFrom:
'@@ -15,7 +15,8 @@ LLMModifier >> getViolationsMessage: violations ['.
self assert: diffRange originalLineRange equals: '-15,7'.
self assert: diffRange newLineRange equals: '+15,8'
]
1 change: 1 addition & 0 deletions src/GLPHExtended-Model-Tests/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'GLPHExtended-Model-Tests' }
2 changes: 1 addition & 1 deletion src/GitLabHealth-Model-Analysis/GitAnalyzer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Class {
'onProject',
'maxChildCommits'
],
#category : #'GitLabHealth-Model-Analysis'
#category : 'GitLabHealth-Model-Analysis'
}

{ #category : #analyze }
Expand Down
2 changes: 1 addition & 1 deletion src/GitLabHealth-Model-Analysis/GitMetric4Group.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Class {
#instVars : [
'project'
],
#category : #'GitLabHealth-Model-Analysis'
#category : 'GitLabHealth-Model-Analysis'
}
2 changes: 1 addition & 1 deletion src/GitLabHealth-Model-Analysis/GitMetric4Project.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Class {
#instVars : [
'project'
],
#category : #'GitLabHealth-Model-Analysis'
#category : 'GitLabHealth-Model-Analysis'
}
2 changes: 1 addition & 1 deletion src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ GitMetricExporter >> initialize [

entities := OrderedCollection new.
"set up the minimal date from which we are looking for the commits a particular user in projects"
sinceTimeLimit := '1 january 2024' asDateAndTime.
sinceTimeLimit := '2024-01-01' asDateAndTime..
runningPeriods := OrderedCollection new.
maxCommitWindow := 3.
over := Date
Expand Down
118 changes: 118 additions & 0 deletions src/GitLabHealth-Model-Extension-Tests/GLHExtensionTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,44 @@ GLHExtensionTest >> testAddAllOfTypeUnlessDifferentEntity [
self assert: (model includes: alreadyExistingUser)
]

{ #category : #tests }
GLHExtensionTest >> testAddAllOfTypeUnlessIntersection [


| user1 user2 user3 user2b user3b user4 result |
user1 := GLHUser new.
user1 id: 1.
user2 := GLHUser new.
user2 id: 2.
user3 := GLHUser new.
user3 id: 3.
model
addAll: {
user1.
user2.
user3 }
unless: [ :a :b | a id = b id ].
self assert: model size equals: 3.
user2b := GLHUser new.
user2b id: 2.
user3b := GLHUser new.
user3b id: 3.
user4 := GLHUser new.
user4 id: 4.

result := model
addAll: {
user2b.
user3b.
user4 }
unless: [ :a :b | a id = b id ].
self assert: model size equals: 4.
self assert: result size equals: 3.
self assert: (result includes: user2).
self assert: (result includes: user3).
self assert: (result includes: user4)
]

{ #category : #tests }
GLHExtensionTest >> testAddAllOfTypeUnlessWithAlreadyExistingEntity [

Expand Down Expand Up @@ -71,3 +109,83 @@ GLHExtensionTest >> testAddAllOfTypeUnlessWithAlreadyExistingEntity [
self assert: (values includes: user).
self assert: (values includes: alreadyExistingUser)
]

{ #category : #tests }
GLHExtensionTest >> testAddAllUnless [

| col |
col := OrderedCollection new.
col addAll: { 12 } unless: [ :a :b | a = b ].
self assert: col size equals: 1.
self assert: col first equals: 12
]

{ #category : #tests }
GLHExtensionTest >> testAddAllUnlessIntersectionOfUsers [

| col result user1 user2 user3 user2b user3b user4 |
user1 := GLHUser new.
user1 id: 1.
user2 := GLHUser new.
user2 id: 2.
user3 := GLHUser new.
user3 id: 3.
col := OrderedCollection new.
col
addAll: {
user1.
user2.
user3 }
unless: [ :a :b | a id = b id ].
self assert: col size equals: 3.
user2b := GLHUser new.
user2b id: 2.
user3b := GLHUser new.
user3b id: 3.
user4 := GLHUser new.
user4 id: 4.

result := col
addAll: {
user2b.
user3b.
user4 }
unless: [ :a :b | a id = b id ].
self assert: col size equals: 4.
self assert: result size equals: 3.
self assert: (result includes: user2).
self assert: (result includes: user3).
self assert: (result includes: user4)
]

{ #category : #tests }
GLHExtensionTest >> testAddAllUnlessTwiceEqualityIsTheSameButNotObject [

| col user result userB |
user := GLHUser new.
user id: 12.
col := OrderedCollection new.
col addAll: { user } unless: [ :a :b | a id = b id ].
self assert: col size equals: 1.
self assert: col first identicalTo: user.
userB := GLHUser new.
userB id: 12.
result := col addAll: { userB } unless: [ :a :b | a id = b id ].
self assert: col size equals: 1.
self assert: result first identicalTo: user
]

{ #category : #tests }
GLHExtensionTest >> testAddAllUnlessTwiceTheSame [

| col user result |
user := GLHUser new.
user id: 12.
col := OrderedCollection new.
col addAll: { user } unless: [ :a :b | a = b ].
self assert: col size equals: 1.
self assert: col first identicalTo: user.
result := col addAll: { user } unless: [ :a :b | a = b ].
self assert: col size equals: 1.
self assert: result first identicalTo: user
]
26 changes: 15 additions & 11 deletions src/GitLabHealth-Model-Extension/MooseAbstractGroup.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ MooseAbstractGroup >> add: anElmt unless: aConditionAsBlock [
{ #category : #'*GitLabHealth-Model-Extension' }
MooseAbstractGroup >> addAll: anElmtCollection ofType: aType unless: aConditionAsBlock [

| addedElement |
addedElement := anElmtCollection reject: [ :anElmt |
(self allWithType: aType) anySatisfy: [
:existingElmt |
aConditionAsBlock value: existingElmt value: anElmt ] ].

self addAll: addedElement.

^ (self allWithType: aType) select: [ :existingElmt |
anElmtCollection anySatisfy: [ :anElmt |
aConditionAsBlock value: anElmt value: existingElmt ] ]
| originalCollection returnCollection |
originalCollection := (self allWithType: aType).
"Create same kind of collection"
returnCollection := self species new.

anElmtCollection do: [ :anElmt |
originalCollection
detect: [ :existingElmt |
aConditionAsBlock value: existingElmt value: anElmt ]
ifFound: [ :el | returnCollection add: el ]
ifNone: [
returnCollection add: anElmt.
self add: anElmt ] ].

^ returnCollection
]

{ #category : #'*GitLabHealth-Model-Extension' }
Expand Down
Loading

0 comments on commit a16cca3

Please sign in to comment.