-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #794 from hernanmd/add_critics_on_class_option
Add critics on class option
- Loading branch information
Showing
3 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
src/NewTools-CodeCritiques/StClassCritiqueBrowserPresenter.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
] |
30 changes: 30 additions & 0 deletions
30
src/NewTools-CodeCritiques/StCritiqueClassRuleSelectorPresenter.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
41
src/NewTools-CodeCritiques/SycCmClassCritiqueCommand.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
] |