1
00:00:01,589 --> 00:00:08,100
Most projects want to have a consistent code style and to follow some conventions and best practices

2
00:00:08,100 --> 00:00:15,390
in the industry, there are multiple tools that can help with analyzing the code and telling if the

3
00:00:15,390 --> 00:00:19,320
code respects the standards or the code style or not.

4
00:00:19,770 --> 00:00:27,750
These tools typically do a static code analysis as the inspection is performed on the files in the project

5
00:00:27,750 --> 00:00:31,320
without actually rewinding the code, without compiling it and so on.

6
00:00:31,920 --> 00:00:37,950
This is in contrast with dynamic analyses which will actually run the code in order to perform some

7
00:00:37,960 --> 00:00:38,640
inspections.

8
00:00:39,670 --> 00:00:46,360
There are many tools that serve many purposes, and one of these tools that can be used for Java projects

9
00:00:46,360 --> 00:00:47,470
is PMed.

10
00:00:47,950 --> 00:00:56,500
PMG can help find and use variables, problematic code blocks and overall to enforce the generally accepted

11
00:00:56,500 --> 00:01:03,460
best practices in the already has a large set of predefined rules, which will also allow you to configure

12
00:01:03,460 --> 00:01:05,379
or add new rules as needed.

13
00:01:05,950 --> 00:01:08,560
PMed is already installed in the Java project.

14
00:01:08,920 --> 00:01:10,530
Let me show you exactly how it works.

15
00:01:12,310 --> 00:01:17,860
In order to run PMed from the terminal, all I have to do is to use the gradle rapper.

16
00:01:20,370 --> 00:01:28,260
And called a tasks PMed, Maine, which will test the Maine code, but also PMed test, which will test

17
00:01:28,260 --> 00:01:30,540
the test classes which are available here.

18
00:01:30,790 --> 00:01:32,910
It will be able to see here Maine and test.

19
00:01:33,210 --> 00:01:35,750
These are two Java specific packages.

20
00:01:43,630 --> 00:01:48,820
You will see in this case that the bill was successful and there are no issues whatsoever with the code

21
00:01:49,660 --> 00:01:51,940
in order to know if this actually works.

22
00:01:52,180 --> 00:01:57,880
We need to find a rule to write the code that will break that rule and to see if everything works.

23
00:01:59,000 --> 00:02:05,390
I am inside the Java rules in best practices, and you will see here only and best practices that are

24
00:02:05,390 --> 00:02:07,620
quite a few rules that we can use.

25
00:02:07,940 --> 00:02:13,760
I'm interested in system print line, which is often used for debugging, and we don't want to have

26
00:02:13,760 --> 00:02:15,380
something like that inside here.

27
00:02:15,860 --> 00:02:21,070
I'm going to copy this and I'm going to place it inside a code just to demonstrate how that works.

28
00:02:22,420 --> 00:02:29,050
The court order application is in insource main Java and there's a package name under here, multiple

29
00:02:29,050 --> 00:02:29,500
classes.

30
00:02:30,040 --> 00:02:32,200
I'm going to go inside the car's application.

31
00:02:33,570 --> 00:02:35,160
Extend the code block here.

32
00:02:36,210 --> 00:02:37,500
And simply paste the code.

33
00:02:41,340 --> 00:02:46,770
If you go back to the terminal and Rwanda, gradle, griper wheat, pmed, Amane ampm to test.

34
00:02:48,260 --> 00:02:50,040
You won't see the build still successful.

35
00:02:50,060 --> 00:02:52,560
Now, the command that we executed is still successful.

36
00:02:52,970 --> 00:02:56,900
This is because we haven't properly configured that are all set currently.

37
00:02:57,860 --> 00:03:02,660
Going back to the documentation, you will see here that for system print line, we can use this tool

38
00:03:02,660 --> 00:03:04,840
by referencing this rule.

39
00:03:04,880 --> 00:03:06,440
So we first have to reference it.

40
00:03:07,380 --> 00:03:13,470
In the project, in the route part of the project, you will find here the PMed ruleset, that X amount.

41
00:03:14,430 --> 00:03:20,880
These are all the rules that we have created here, because I have specified here some custom rules

42
00:03:20,910 --> 00:03:24,130
we need to define again, which rules we actually want to use.

43
00:03:24,480 --> 00:03:29,400
I'm going to paste inside here this system print line rule and we'll save it.

44
00:03:29,700 --> 00:03:31,290
And then we're rewriting this.

45
00:03:34,240 --> 00:03:39,280
We'll see here that there's a violation and that their report has been generated.

46
00:03:40,590 --> 00:03:46,620
We can view the contents of this report, which is an example, by hovering over the file and clicking

47
00:03:46,620 --> 00:03:50,610
the browser, you will see that a report is not very nice.

48
00:03:50,610 --> 00:03:56,640
But it still tells us that in this file card application that Java on line 10, we have used system

49
00:03:56,670 --> 00:03:57,480
out print line.

50
00:03:59,070 --> 00:04:04,950
So at the very simple level, this is how static court analyses can help projects maintain a healthy

51
00:04:04,950 --> 00:04:10,820
state and to ensure that all the developers working on the project adhere to a predefined set of rules.

