Advanced Workflow
Walk you through the suggested advanced workflow for using Codee, demonstrated with a Fortran open source project.
Getting ready
At the end of the Basic Workflow we generated a compilation database to efficiently handle the compiler invocations for different source files. In this advanced workflow we will review some of the additional reports that other Codee commands can generate.
Start by cloning the repository if necessary:
git clone https://github.com/codee-com/codee-demos.git
Walkthrough of the workflow
0. Compilation Database
First, navigate to the source code directory:
- Linux
- Windows
cd codee-demos/Fortran/Himeno
cd codee-demos\Fortran\Himeno
Now we will review the different reports that Codee generates besides the checks report.
1. Technical Debt
This report quantifies as a single number, the technical debt score, all code refactors that are necessary to leverage all improvement opportunities identified by Codee. Over time, your goal should be to progressively reduce this score to zero:
codee technical-debt -p build/compile_commands.json
TECHNICAL DEBT REPORT
This report quantifies the technical debt associated with the modernization of legacy code by assessing the extent of refactoring required for language constructs. The score is determined based on the number of language constructs necessitating refactoring to bring the source code up to modern standards. Additionally, the metric identifies the impacted source code segments, detailing affected files, functions, and loops.
Score Affected files Affected functions Affected loops
----- -------------- ------------------ --------------
18 1 7 0
TECHNICAL DEBT BREAKDOWN
Lines of code Analysis time Checkers Technical debt score
------------- ------------- -------- --------------------
214 124 ms 18 18
The listing of language constructs associated with legacy code found in the source code is as follows:
- PAUSE
SUGGESTIONS
Use 'checks' to find out details about the detected checks:
codee checks -- gfortran -c himeno.f90
1 file, 7 functions, 5 loops successfully analyzed and 0 non-analyzed files in 126 ms
2. Screening with Ranking
While the technical debt report provides guidance on how many issues there are, the screening report details which recommendations of the Open Catalog are applicable to the code, and ranks them based on their estimated positive impact to help prioritize the refactoring efforts:
codee screening -p build/compile_commands.json
SCREENING REPORT
---Number of files---
Total | C C++ Fortran
----- | - --- -------
1 | 0 0 1
RANKING OF QUALITY CHECKERS
Checker Category Priority AutoFixes # Title
------- ----------- -------- --------- -- ---------------------------------------------------------------------------------------
PWR063 modern P12 (L1) 1 Avoid using legacy Fortran constructs
PWR068 correctness P9 (L2) 5 Encapsulate procedures within modules to avoid the risks of calling implicit interfaces
PWR069 correctness P6 (L2) 6 6 Use the keyword only to explicitly state what to import from a module
PWR001 correctness P1 (L3) 5 Declare global variables as function parameters
------- ----------- -------- --------- -- ---------------------------------------------------------------------------------------
Total 6 17
SUGGESTIONS
Use 'roi' to get a return of investment estimation report:
codee roi -- gfortran -c himeno.f90
Use 'checks' to find out details about the detected checks:
codee checks -- gfortran -c himeno.f90
1 file, 7 functions, 5 loops, 214 LOCs successfully analyzed (17 checkers) and 0 non-analyzed files in 285 ms
3. ROI
Once we have an overview of all the identified improvement opportunities, the ROI report estimates the effort and time savings realized through the automated analysis that Codee has just performed. The estimation compares the time that would have been needed to manually evaluate each part of the code analyzed against every rule in the Open Catalog to identify the improvement opportunities:
codee roi -p build/compile_commands.json
ROI ANALYSIS SUMMARY
This analysis underscores the tangible benefits Codee brings to the development process, not only in terms of savings in development effort, but also in realizing significant cost efficiencies for the organization.
Impact on Development Effort:
This report identifies critical areas within the source code that necessitate attention from the development team, and forecasts a significant reduction in workload by an estimated 60 hours.
Without Codee | With Codee | Hours saved
------------- | ---------- | -----------
78 hours | 18 hours | 60 hours
Impact on Cost Savings:
Considering a standard developer's workload of approximately 1800 hours/year, Codee's intervention translates to saving an equivalent to 0.03 (60h / 1800h) developers working full-time. Assuming an average cost of a developer for the company (salary + associated costs) of €100,000, this amounts to cost savings of €3,333 (€100,000 x 0.03).
Developer hours/year | Number of devs. saved/year | Developer salary/year | Total costs saved/year
-------------------- | -------------------------- | --------------------- | ----------------------
1800 hours | 0.03 | €100,000 | €3,333
SUGGESTIONS
Set custom parameters for the ROI calculation, using --dev-cost-per-year, --dev-hours-per-year, and --checker-effort flags; e.g.:
codee roi --dev-cost-per-year 20000 --dev-hours-per-year 1600 --checker-effort 1.5 -- gfortran -c himeno.f90
Use --check-id <list of checkers separated by comma> to calculate the ROI for an arbitrary subset of checkers to enable; e.g.:
codee roi --check-id PWR030,PWR039 -- gfortran -c himeno.f90
1 file, 7 functions, 5 loops, 214 LOCs successfully analyzed (18 checkers) and 0 non-analyzed files in 222 ms
ROI ANALYSIS SUMMARY
This analysis underscores the tangible benefits Codee brings to the development process, not only in terms of savings in development effort, but also in realizing significant cost efficiencies for the organization.