Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add critics on class option #794

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
]
Loading