Skip to content

Commit

Permalink
Merge pull request #794 from hernanmd/add_critics_on_class_option
Browse files Browse the repository at this point in the history
Add critics on class option
  • Loading branch information
jecisc committed Jul 16, 2024
2 parents 18347ae + cfb3e47 commit a3eefab
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"
Implements a presenter that allows get a list of critiques that broken the selected rules in the selected classes.
It interacts with StCritiquePackageSelectorPresenter to get the list of selected packages.
I interact with StCritiqueRuleSelectorPresenter to get the list of selected rules.
I interact with StCritiquesCache to get the critiques saved as 'To-do' and marked as 'false positive'.
## Examples
`StClassCritiqueBrowserPresenter open`
"
Class {
#name : 'StClassCritiqueBrowserPresenter',
#superclass : 'StCritiqueBrowserPresenter',
#category : 'NewTools-CodeCritiques-Base',
#package : 'NewTools-CodeCritiques',
#tag : 'Base'
}

{ #category : 'menu' }
StClassCritiqueBrowserPresenter class >> openOnCurrentWorkingConfiguration [

<script>
CBCritiqueWorkingConfiguration exists
ifTrue: [ StResetWindowPresenter new open ]
ifFalse: [ StClassCritiqueRuleSelectorPresenter open ]
]

{ #category : 'private' }
StClassCritiqueBrowserPresenter >> applyRules [

| process |

self updateTree.
checker environment: rbEnvironment.
process := [ self processRules ] newProcess.
process name: 'SmallLint'.
process resume
]

{ #category : 'private' }
StClassCritiqueBrowserPresenter >> processRules [

| packageCount nbPackage rules |

nbPackage := rbEnvironment packages size.
packageCount := 0.
rules := self allRules.

rbEnvironment classes do: [ :cls |
| windowTitle |
packageCount := packageCount + 1.
windowTitle := String streamContents: [ :s |
s << 'run rules on ' << cls name << ' ('
<< packageCount asString << '/'
<< nbPackage asString << ')' ].
self setTitle: windowTitle.
checker
classRules: rules;
checkClass: cls ].
checker rule: rules.
self setTitle: self defaultTitle.
cache packages: rbEnvironment.
cache initCache.
self rules: (self allRules select: [ :r | self hasBrokenRules: r ]).
self rulesModel refresh.
self rebuildLayout.
self updateTree
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"
## Example
```
StCritiqueClassRuleSelectorPresenter
openWithEnvironment: (RBClassEnvironment new classes: { ReClassForGeneratingEqualAndHashExistingImplementors })
removeTestCase: false.
```
"
Class {
#name : 'StCritiqueClassRuleSelectorPresenter',
#superclass : 'StCritiqueRuleSelectorPresenter',
#category : 'NewTools-CodeCritiques-Applier',
#package : 'NewTools-CodeCritiques',
#tag : 'Applier'
}

{ #category : 'adding' }
StCritiqueClassRuleSelectorPresenter >> nextAction [

self delete.

CBCritiqueWorkingConfiguration current
rule: selectedRules;
environment: environment;
removeTestCase: removeTestCase.
StClassCritiqueBrowserPresenter openOnWorkingConfiguration:
CBCritiqueWorkingConfiguration current
]
41 changes: 41 additions & 0 deletions src/NewTools-CodeCritiques/SycCmClassCritiqueCommand.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"
I am a command to make a class abstract by adding a method that returns whether the class is abstract
"
Class {
#name : 'SycCmClassCritiqueCommand',
#superclass : 'SycClassCmCommand',
#category : 'NewTools-CodeCritiques-Commands',
#package : 'NewTools-CodeCritiques',
#tag : 'Commands'
}

{ #category : 'testing' }
SycCmClassCritiqueCommand >> canBeExecuted [

^ context lastSelectedClass realClass notNil
]

{ #category : 'executing' }
SycCmClassCritiqueCommand >> execute [

StCritiqueClassRuleSelectorPresenter
openWithEnvironment: (RBClassEnvironment new classes: { context lastSelectedClass realClass })
removeTestCase: false.

]

{ #category : 'accessing' }
SycCmClassCritiqueCommand >> icon [

^ self iconNamed: #smallQA
]

{ #category : 'accessing' }
SycCmClassCritiqueCommand >> name [
^ 'Class Critique Browser'
]

{ #category : 'accessing' }
SycCmClassCritiqueCommand >> order [
^ 45
]

0 comments on commit a3eefab

Please sign in to comment.