Skip to content
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
6 changes: 0 additions & 6 deletions courses/gnatsas/examples/README.md

This file was deleted.

5 changes: 0 additions & 5 deletions courses/gnatsas/examples/gnatcheck/getting_started/README.md

This file was deleted.

9 changes: 0 additions & 9 deletions courses/gnatsas/examples/gnatmetric/main.adb

This file was deleted.

5 changes: 0 additions & 5 deletions courses/gnatsas/examples/tutorial/README.md

This file was deleted.

4 changes: 2 additions & 2 deletions courses/gnatsas/labs/check_020_getting_started.lab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
GNATcheck Getting Started Lab
-------------------------------

* Copy the :filename:`getting_started` folder from the course materials location
* Copy the :filename:`check_020_getting_started` folder from the course materials location

* Contents of the folder:

Expand All @@ -15,7 +15,7 @@ GNATcheck Getting Started Lab
Preparing the Command Line
----------------------------

1. Open a command prompt window and navigate to the :filename:`getting_started` folder
1. Open a command prompt window and navigate to the :filename:`check_020_getting_started` folder

2. Type :command:`gnatcheck` and press :menu:`Enter` to verify tool is on your path

Expand Down
23 changes: 18 additions & 5 deletions courses/gnatsas/labs/check_040_lkql.lab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ To flag those type declarations we must define a criteria list:

We're going to see how to express those criteria using LKQL.

-----------------
Example Project
-----------------

* Copy the :filename:`check_40_lkql` folder from the course materials location

* Contents of the folder:

* :filename:`default.gpr` - project file
* :filename:`src` - source directory

* Contains package :ada:`test_pkg` with some example integer-based definitions (as seen on the next two slides)

---------------------------
Source Code Specification
---------------------------
Expand Down Expand Up @@ -98,7 +111,7 @@ Step 1 - Flag All Integers

3. Test it out - see what happens when you run the rule::

gnatcheck -P prj.gpr --rules-dir=. -rules +Renum_for_integer
gnatcheck -P default.gpr --rules-dir=. -rules +Renum_for_integer

* This gives us the output::

Expand Down Expand Up @@ -184,7 +197,7 @@ Step 4 - Use First Criteria in Rule

2. Test it out - see what happens when you run the rule::

gnatcheck -P prj.gpr --rules-dir=. -rules +Renum_for_integer
gnatcheck -P default.gpr --rules-dir=. -rules +Renum_for_integer

* This gives us the output::

Expand Down Expand Up @@ -249,7 +262,7 @@ Step 6 - Improve Types Filter

2. Test it out - see what happens when you run the rule::

gnatcheck -P prj.gpr --rules-dir=. -rules +Renum_for_integer
gnatcheck -P default.gpr --rules-dir=. -rules +Renum_for_integer

* This gives us the output::

Expand Down Expand Up @@ -284,7 +297,7 @@ Step 7 - Implement Third Criteria

2. And once again test it out

gnatcheck -P prj.gpr --rules-dir=. -rules +Renum_for_integer
gnatcheck -P default.gpr --rules-dir=. -rules +Renum_for_integer

* This gives us the output::

Expand Down Expand Up @@ -396,7 +409,7 @@ Final Result

* One more run to get the "correct" result

gnatcheck -P prj.gpr --rules-dir=. -rules +Renum_for_integer
gnatcheck -P default.gpr --rules-dir=. -rules +Renum_for_integer

* This gives us the output

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project Prj is
project Default is
for Source_Dirs use ("src");
for Object_Dir use "obj";
for Main use ("main.adb");
end Prj;
end Default;
139 changes: 28 additions & 111 deletions courses/gnatsas/labs/metric_010_overview.lab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@
GNATmetric Lab Setup
----------------------

* Copy the :filename:`tutorial` folder from the course materials location
* Copy the :filename:`metric_010_overview` folder from the course materials location

* Contents of the tutorial folder:

* :filename:`sdc.gpr` - project file
* :filename:`common` - source directory
* :filename:`struct` - source directory
* :filename:`obj` - object file (and metrics results) directory
* This folder contains a project file (:filename:`default.gpr`) and some Ada source files

* From a command prompt, type :command:`gnatmetric --help` to verify your path is set correctly

Expand All @@ -20,9 +15,9 @@ GNATmetric Lab Setup
GNATmetric Lab - GUI Part 1
-----------------------------

* Use :toolname:`GNAT Studio` to open the project :filename:`sdc.gpr`
* Use :toolname:`GNAT Studio` to open the project :filename:`default.gpr`

* Select :filename:`instructions.adb` in the :filename:`struct` folder
* Open :filename:`line_metrics_example.adb`

* Perform metrics analysis to get all line metrics on this file

Expand All @@ -31,41 +26,19 @@ GNATmetric Lab - GUI Part 1

.. container:: animate 1-

Question 1

.. container:: columns

.. container:: column

.. container:: animate 1-

* How many lines in the file? In subprogram :ada:`Process`?

.. container:: column
* Question 1: How many lines in the file? In subprogram :ada:`Example`?

.. container:: animate 2-

59 lines in the file
.. container:: animate 2-

20 lines in Process
19 lines in the file, 8 lines in :ada:`Example`

.. container:: animate 3-

Question 2

.. container:: columns

.. container:: column

.. container:: animate 3-
* Question 2: Is there any information for the package spec?

* Is there any information for the package spec?
.. container:: animate 4-

.. container:: column

.. container:: animate 4-

No - :menu:`Current File` means actual file, not package
No - :menu:`Current File` means actual file, not package

-----------------------------
GNATmetric Lab - GUI Part 2
Expand All @@ -80,91 +53,45 @@ Perform metrics analysis to get all complexity metrics in the project

.. container:: animate 3-

Question 1

.. container:: columns

.. container:: column

.. container:: animate 3-
* Question 1: What is the average complexity for project? :ada:`complexity_metrics_example.adb`?

* What is the average complexity for the project? :ada:`stack.adb`?
.. container:: animate 4-

.. container:: column

.. container:: animate 4-

2.3

1.7
1.3 for the project, 2 for the file

.. container:: animate 5-

Question 2

.. container:: columns

.. container:: column
* Question 2: Which file has an statement complexity of 1.5?

.. container:: animate 5-
.. container:: animate 6-

* Which file has an essential complexity of 1?

.. container:: column

.. container:: animate 6-

:filename:`sdc.adb`
:filename:`line_metrics_example.adb`

-----------------------------
GNATmetric Lab - CLI Part 1
-----------------------------

* Use the command line to generate syntax elements metrics for the project

:command:`gnatmetric -Psdc.gpr -U --syntax-all`
:command:`gnatmetric -Pdefault.gpr -U --syntax-all`

.. container:: animate 1-

Question 1

.. container:: columns

.. container:: column

.. container:: animate 1-
* Question 1: How many total statements in the project? Declarations?

* How many total statements and declarations in the project?

.. container:: column

.. container:: animate 2-

Statements - 160
.. container:: animate 2-

Declarations - 195
16 statements, 70 declarations

.. container:: animate 3-

Question 2

.. container:: columns
* Question 2: What are the number of statements and declarations for :ada:`From_String` in package :ada:`Syntax_Metrics_Example`?

.. container:: column
.. container:: animate 4-

.. container:: animate 3-
3 statements, 4 declarations

* What are the number of statements and declarations for procedure :ada:`Push` in package :ada:`Stack`?

.. container:: column

.. container:: animate 4-

Statements - 5

Declarations - 2

You need to open the file ``obj\stack.adb.metrix`` to get the data
You need to open the file ``obj\syntax_metrics_example.adb.metrix`` to get the data

-----------------------------
GNATmetric Lab - CLI Part 2
Expand All @@ -174,22 +101,12 @@ Generate a local version of the combined XML metrics file for coupling metrics w

.. container:: animate 2-

``gnatmetric -Psdc.gpr -U --coupling-all --no-text-output --xml-file-name=.\local.xml``
``gnatmetric -Pdefault.gpr -U --coupling-all --no-text-output --xml-file-name=.\local.xml``

.. container:: animate 3-

Question

.. container:: columns

.. container:: column

.. container:: animate 3-

* How many total lines in the generated XML file?

.. container:: column
* Question: How many total lines in the generated XML file?

.. container:: animate 4-
.. container:: animate 4-

118
100
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package Coupling_Metrics_Dependency is

type Record_T is tagged private;
function Set (A, B : Integer) return Record_T;
function Get (A : Record_T) return Integer;
function Add (A, B : Record_T) return Record_T;
function Set
(A, B : Integer)
return Record_T;
function Get
(A : Record_T)
return Integer;
function Add
(A, B : Record_T)
return Record_T;

private
type Record_T is tagged record
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
with Coupling_Metrics_Dependency;
use Coupling_Metrics_Dependency;
with Coupling_Metrics_Dependency; use Coupling_Metrics_Dependency;
package Coupling_Metrics_Example is

procedure Example (L, R : Record_T);
Expand Down
8 changes: 8 additions & 0 deletions courses/gnatsas/labs/metric_010_overview/default.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
project Default is

for Source_Dirs use (".");
for Object_Dir use "obj";
for Main use ("main.adb");

end Default;

18 changes: 18 additions & 0 deletions courses/gnatsas/labs/metric_010_overview/main.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
with Coupling_Metrics_Dependency; use Coupling_Metrics_Dependency;

with Coupling_Metrics_Example;
with Complexity_Metrics_Example;
with Line_Metrics_Example;
with Syntax_Metrics_Example;

procedure Main is
Coupling_Object_A : constant Record_T := Set (1, 2);
Coupling_Object_B : constant Record_T := Set (30, 40);
Complexity_Object : String := "Hello World";
Syntax_Object : Syntax_Metrics_Example.String_T;
begin
Coupling_Metrics_Example.Example (Coupling_Object_A, Coupling_Object_B);
Complexity_Metrics_Example.Example (Complexity_Object);
Line_Metrics_Example.Example ("Hello", "World");
Syntax_Object := Syntax_Metrics_Example.From_String ("Hello");
end Main;
Loading