Hi guys, so Iâm experimenting with rules, and I have one simple question: how do I get a collection of items from some environment which violate some rule? i know that I can send #runOnEnvironment: to the rule itself and then it will use a checker to run the rule on the environment. But later I end up with the rule itself. I know that I can get all atomic rules from composite rule by sending #leaves, and there is #result method that returns environment. But there is no single way to get items from environment, and all accessors are environment-specific. Am I doing something wrong? Because Iâve spent half of a day to find out how to run a rule and get violations :). Cheers. Uko
Yeah, all the refatory stuff has weird API and SmallLint ones are of the weirdest. The design is bit unfortunate. You may want to have a look how I did it: RBLintRule>>failedMethods, RBLintRule>>failedClasses source code's here: http://www.exept.de/cgi-bin/viewvc.cgi/stx/goodies/refactoryBrowser/lint/RBL... Best, Jan On 22/05/14 15:49, Yuriy Tymchuk wrote:
Hi guys,
so Iâm experimenting with rules, and I have one simple question: how do I get a collection of items from some environment which violate some rule?
i know that I can send #runOnEnvironment: to the rule itself and then it will use a checker to run the rule on the environment. But later I end up with the rule itself. I know that I can get all atomic rules from composite rule by sending #leaves, and there is #result method that returns environment. But there is no single way to get items from environment, and all accessors are environment-specific. Am I doing something wrong? Because Iâve spent half of a day to find out how to run a rule and get violations :).
Cheers. Uko
If you improve the system send us fixes. Just make sure that - the tests run - you add tests. Stef
Iâd gladly submit improvements, but I need some background knowledge. Whatâs the plan? It looks like SmalllintManifestChecker is just overriding/fixing stuff that is wrong in RBSmalllintChecker. For example RBSmalllintChecker>>checkClass: does: â(environment includesClass: aClass) ifTrue:â while SmalllintManifestChecker>>runRules:onPackage:withoutTestCase: does: â(environment definesClass: class) ifTrue:â. SmalllintManifestChecker>>runRules:onPackage: doesnât do this check despite that fact that it should work similarly to SmalllintManifestChecker>>runRules:onPackage:withoutTestCase:. Do we need to flatten SmalllintManifestChecker into RBSmalllintChecker? What is the status, is anyone working on it with some purpose or not? Also SmallLint is tied with RB. Is RB going to change or not? Uko On 22 May 2014, at 18:54, stepharo <stepharo@free.fr> wrote:
If you improve the system send us fixes. Just make sure that - the tests run - you add tests.
Stef
Hi Jan, in #failedMethods: you use #failedMethodsInto: which is abstract. So the idea is that in each rule gets methods from itâs result? Uko On 22 May 2014, at 17:03, Jan Vrany <jan.vrany@fit.cvut.cz> wrote:
Yeah,
all the refatory stuff has weird API and SmallLint ones are of the weirdest. The design is bit unfortunate. You may want to have a look how I did it:
RBLintRule>>failedMethods, RBLintRule>>failedClasses
source code's here: http://www.exept.de/cgi-bin/viewvc.cgi/stx/goodies/refactoryBrowser/lint/RBL...
Best, Jan
On 22/05/14 15:49, Yuriy Tymchuk wrote:
Hi guys,
so Iâm experimenting with rules, and I have one simple question: how do I get a collection of items from some environment which violate some rule?
i know that I can send #runOnEnvironment: to the rule itself and then it will use a checker to run the rule on the environment. But later I end up with the rule itself. I know that I can get all atomic rules from composite rule by sending #leaves, and there is #result method that returns environment. But there is no single way to get items from environment, and all accessors are environment-specific. Am I doing something wrong? Because Iâve spent half of a day to find out how to run a rule and get violations :).
Cheers. Uko
No. not really. There are just 4 implementors only, in RBBasicLintRule, RBTransformationRule and RBCompositeLintRule. Maybe I've added something to environment, I don't really remember, it's a long time ago when worked on this and since then it just works :-) If you'd like more convenient way to browse the code, you may want to download and run St/X and look at it in browser: https://swing.fit.cvut.cz/projects/stx-jv/wiki/Download SmallLint is pre-loaded. Jan On 22/05/14 16:18, Yuriy Tymchuk wrote:
Hi Jan,
in #failedMethods: you use #failedMethodsInto: which is abstract. So the idea is that in each rule gets methods from itâs result?
Uko
On 22 May 2014, at 17:03, Jan Vrany <jan.vrany@fit.cvut.cz> wrote:
Yeah,
all the refatory stuff has weird API and SmallLint ones are of the weirdest. The design is bit unfortunate. You may want to have a look how I did it:
RBLintRule>>failedMethods, RBLintRule>>failedClasses
source code's here: http://www.exept.de/cgi-bin/viewvc.cgi/stx/goodies/refactoryBrowser/lint/RBL...
Best, Jan
On 22/05/14 15:49, Yuriy Tymchuk wrote:
Hi guys,
so Iâm experimenting with rules, and I have one simple question: how do I get a collection of items from some environment which violate some rule?
i know that I can send #runOnEnvironment: to the rule itself and then it will use a checker to run the rule on the environment. But later I end up with the rule itself. I know that I can get all atomic rules from composite rule by sending #leaves, and there is #result method that returns environment. But there is no single way to get items from environment, and all accessors are environment-specific. Am I doing something wrong? Because Iâve spent half of a day to find out how to run a rule and get violations :).
Cheers. Uko
Ha, Iâve found the solution. Something around this lines: checker := SmalllintManifestChecker new rule: rules; environment: env; run. (rules leaves collect: [ :rule | rule -> (checker criticsOf: rule) ] thenReject: [ :assoc | assoc value isEmpty ]) asDictionary Uko On 22 May 2014, at 17:27, Jan Vrany <jan.vrany@fit.cvut.cz> wrote:
No. not really.
There are just 4 implementors only, in RBBasicLintRule, RBTransformationRule and RBCompositeLintRule.
Maybe I've added something to environment, I don't really remember, it's a long time ago when worked on this and since then it just works :-)
If you'd like more convenient way to browse the code, you may want to download and run St/X and look at it in browser:
https://swing.fit.cvut.cz/projects/stx-jv/wiki/Download
SmallLint is pre-loaded.
Jan
On 22/05/14 16:18, Yuriy Tymchuk wrote:
Hi Jan,
in #failedMethods: you use #failedMethodsInto: which is abstract. So the idea is that in each rule gets methods from itâs result?
Uko
On 22 May 2014, at 17:03, Jan Vrany <jan.vrany@fit.cvut.cz> wrote:
Yeah,
all the refatory stuff has weird API and SmallLint ones are of the weirdest. The design is bit unfortunate. You may want to have a look how I did it:
RBLintRule>>failedMethods, RBLintRule>>failedClasses
source code's here: http://www.exept.de/cgi-bin/viewvc.cgi/stx/goodies/refactoryBrowser/lint/RBL...
Best, Jan
On 22/05/14 15:49, Yuriy Tymchuk wrote:
Hi guys,
so Iâm experimenting with rules, and I have one simple question: how do I get a collection of items from some environment which violate some rule?
i know that I can send #runOnEnvironment: to the rule itself and then it will use a checker to run the rule on the environment. But later I end up with the rule itself. I know that I can get all atomic rules from composite rule by sending #leaves, and there is #result method that returns environment. But there is no single way to get items from environment, and all accessors are environment-specific. Am I doing something wrong? Because Iâve spent half of a day to find out how to run a rule and get violations :).
Cheers. Uko
participants (3)
-
Jan Vrany -
stepharo -
Yuriy Tymchuk