WEBVTT

00:00:01.260 --> 00:00:03.390 align:middle
In this video, I’d like to show
you that Pharo

00:00:03.557 --> 00:00:06.040 align:middle
also offers the possiblity
to have an assistant that

00:00:06.207 --> 00:00:08.640 align:middle
checks your code quality,
it is called either

00:00:08.807 --> 00:00:11.450 align:middle
the Quality Assistant, or
Code Critics. It runs

00:00:11.617 --> 00:00:14.770 align:middle
automatically good practice rules
on your code.

00:00:15.710 --> 00:00:17.040 align:middle
Let’s have a look at it
more closely.

00:00:17.300 --> 00:00:19.220 align:middle
You’ve seen that each time you 
browse a class,

00:00:19.387 --> 00:00:22.770 align:middle
you have this pop-up that
is displayed.

00:00:22.937 --> 00:00:25.300 align:middle
In fact, what happens is that
automatically,

00:00:25.467 --> 00:00:27.770 align:middle
while I’m browsing, 

00:00:27.937 --> 00:00:32.010 align:middle
(let’s choose CubHelix
to see),you have

00:00:32.177 --> 00:00:35.740 align:middle
this little area here
where indications

00:00:37.020 --> 00:00:40.390 align:middle
are displayed. And when I go
on the package also.

00:00:43.110 --> 00:00:46.350 align:middle
As it is a little bit difficult
to find a  

00:00:46.517 --> 00:00:49.240 align:middle
convincing example, we will
use our own code and 

00:00:49.407 --> 00:00:52.090 align:middle
write ugly code in it, this way 
you will see.

00:00:52.280 --> 00:00:57.080 align:middle
If I go into Counter, let’s imagine
for example that

00:00:57.247 --> 00:01:00.480 align:middle
I leave debugging code,

00:01:02.350 --> 00:01:04.730 align:middle
here the system tells me
automatically 2 things.

00:01:05.180 --> 00:01:09.310 align:middle
It says that there is debugging 
code left

00:01:09.477 --> 00:01:12.200 align:middle
in the method. 
What can I do ?

00:01:12.940 --> 00:01:14.540 align:middle
I can understand where does
this rule come from.

00:01:14.707 --> 00:01:16.680 align:middle
So I click on it, it tells me
to use 

00:01:16.847 --> 00:01:19.800 align:middle
breakpoints, which is not 
specially smart in production code.

00:01:21.280 --> 00:01:25.260 align:middle
It can tell me, I will automatically
solve this problem.

00:01:25.427 --> 00:01:26.340 align:middle
Let’s try, we will see.

00:01:27.300 --> 00:01:28.530 align:middle
It says to suppress this.

00:01:28.720 --> 00:01:30.240 align:middle
Ok, very good.

00:01:30.950 --> 00:01:32.710 align:middle
And as a consequence, I 
don’t have this problem anymore.

00:01:34.540 --> 00:01:36.700 align:middle
You’ve seen that we do it
while I am

00:01:36.867 --> 00:01:40.100 align:middle
programming.
Finally, the system will react.

00:01:40.460 --> 00:01:43.350 align:middle
Now, there is another way to do it,
I can

00:01:43.517 --> 00:01:48.250 align:middle
open the Critic browser on
my package.

00:01:48.417 --> 00:01:49.460 align:middle
here it is a very small package.

00:01:50.960 --> 00:01:55.460 align:middle
Let’s make a mistake in order to 
see it.

00:01:55.627 --> 00:01:56.440 align:middle
Here if I do "self halt"

00:02:01.020 --> 00:02:02.790 align:middle
or far example I do another
method,

00:02:03.460 --> 00:02:06.910 align:middle
I create an “increment3” method
and

00:02:07.077 --> 00:02:08.790 align:middle
I invoke a method which
doesn’t exist.

00:02:08.957 --> 00:02:11.740 align:middle
Let’s call it "foofoo".

00:02:13.110 --> 00:02:16.010 align:middle
So here it is red but let’s suppose
I haven’t

00:02:16.177 --> 00:02:18.900 align:middle
noticed it because of a 
feverishness state…

00:02:20.590 --> 00:02:24.360 align:middle
I’m gonna use the Critic browser

00:02:27.380 --> 00:02:31.250 align:middle
on my code and here 
the Critic browser

00:02:31.417 --> 00:02:32.770 align:middle
shows me the set of rules.

00:02:33.720 --> 00:02:38.620 align:middle
There is in fact quite a lot
rules 

00:02:38.787 --> 00:02:42.790 align:middle
with explanations. If you have
this code there, in this

00:02:42.957 --> 00:02:46.200 align:middle
case you’d better use it
that way, if there is

00:02:46.367 --> 00:02:47.450 align:middle
an allocation inside.

00:02:47.617 --> 00:02:49.620 align:middle
There are several kinds of rules.

00:02:50.040 --> 00:02:52.160 align:middle
There are rules linked to 
optimisation, rules

00:02:52.327 --> 00:02:54.300 align:middle
that can potentially identify
fixed bugs.

00:02:54.650 --> 00:02:56.600 align:middle
Rules that identify true.

00:02:56.860 --> 00:02:59.200 align:middle
If I go there, I see the code.

00:02:59.367 --> 00:03:03.050 align:middle
I can browse the definition 
as we did before,

00:03:03.217 --> 00:03:05.810 align:middle
or I can transform it.

00:03:08.180 --> 00:03:12.160 align:middle
And the warning disappeared.

00:03:13.610 --> 00:03:15.400 align:middle
Now it is important to notice 
that

00:03:15.567 --> 00:03:17.920 align:middle
all these rules are based
on heuristics.

00:03:18.087 --> 00:03:19.700 align:middle
This means that sometimes
you do things 

00:03:19.867 --> 00:03:22.840 align:middle
that are not very good.
You know it and you

00:03:23.007 --> 00:03:24.200 align:middle
have to let it that way in
the system.

00:03:24.367 --> 00:03:28.840 align:middle
You can also say that this 
is a false

00:03:29.007 --> 00:03:33.660 align:middle
positive. Let’s imagine
I have a “foofoo”

00:03:33.827 --> 00:03:36.660 align:middle
message and I know I want to 
keep it, I can

00:03:36.827 --> 00:03:40.240 align:middle
specify that this rule is false
for this method.

00:03:41.850 --> 00:03:44.850 align:middle
I will write it.

00:03:45.017 --> 00:03:46.510 align:middle
Here it is in grey, what
does it mean?

00:03:46.677 --> 00:03:49.690 align:middle
It means that later I could
look at it

00:03:49.857 --> 00:03:51.310 align:middle
and say myself maybe this rule
was true and

00:03:51.477 --> 00:03:53.490 align:middle
it made sense to take another

00:03:57.250 --> 00:03:57.883 align:middle
look at it.

00:03:58.410 --> 00:04:00.640 align:middle
We can save the critics.

00:04:00.807 --> 00:04:04.910 align:middle
It means we save the rules results 
and

00:04:05.077 --> 00:04:06.670 align:middle
as well the false positives.

00:04:07.290 --> 00:04:08.850 align:middle
When we write something was false,
we don’t want

00:04:09.017 --> 00:04:11.000 align:middle
the system to repeat it
constanltly

00:04:11.167 --> 00:04:12.680 align:middle
each time we run the rules.

00:04:13.400 --> 00:04:18.230 align:middle
So when I save the critics,
it will put them in a manifest.

00:04:18.470 --> 00:04:21.690 align:middle
Let’s look at it. Here there
is my manifest which will

00:04:21.857 --> 00:04:23.920 align:middle
be assigned a version
associated with the system.

00:04:24.087 --> 00:04:26.410 align:middle
You don’t need to see how it is coded
inside, we don’t care.

00:04:26.577 --> 00:04:29.400 align:middle
The Manifest enables to code
things,but no matter.

00:04:29.700 --> 00:04:32.590 align:middle
You don’t touch to this, this is the 
code-critics that will use it

00:04:32.757 --> 00:04:34.120 align:middle
for the next executions.

00:04:34.287 --> 00:04:36.260 align:middle
And you have a manifest for each 
package.

00:04:36.700 --> 00:04:38.100 align:middle
When you assign a version to
the code, you

00:04:38.267 --> 00:04:39.920 align:middle
also assign a version to your
manifests, and when you

00:04:40.087 --> 00:04:42.880 align:middle
run again your code-critics,
automatically it

00:04:43.047 --> 00:04:44.890 align:middle
will take into account
all the false positives and all

00:04:45.057 --> 00:04:47.040 align:middle
the meta-remarks you
put in it.

00:04:47.207 --> 00:04:49.510 align:middle
So what is really interesting
with those quality

00:04:49.677 --> 00:04:53.390 align:middle
rules is that Pharo integrates
them in a development process.

00:04:53.557 --> 00:04:56.010 align:middle
We will make sure that,

00:04:56.177 --> 00:04:58.570 align:middle
each time you commit your project,
there are 

00:04:58.737 --> 00:05:01.170 align:middle
Jenkins servers
that will load and run

00:05:01.337 --> 00:05:04.000 align:middle
automatically those quality 
rules to check that

00:05:04.167 --> 00:05:05.920 align:middle
your program really follows
those rules.

