PageSourceSearch

https://www.sokrates.dev/book/

html sokrates.dev collected 2026-09-25 22:14:51 UTC 25,036 bytes, 571 lines download raw bytes

1<!DOCTYPE html>
2<html lang="en"><head>
3  <meta charset="utf-8">
4  <meta http-equiv="X-UA-Compatible" content="IE=edge">
5  <meta name="viewport" content="width=device-width, initial-scale=1"><!-- Begin Jekyll SEO tag v2.6.1 -->
6<title>Examined Line: The Art of Source Code Analysis with Sokrates | A collection of articles on source code analysis with Sokrates.</title>
7<meta name="generator" content="Jekyll v4.0.0" />
8<meta property="og:title" content="Examined Line: The Art of Source Code Analysis with Sokrates" />
9<meta property="og:locale" content="en_US" />
10<meta name="description" content="A collection of articles on source code analysis with Sokrates." />
11<meta property="og:description" content="A collection of articles on source code analysis with Sokrates." />
12<link rel="canonical" href="/book/" />
13<meta property="og:url" content="/book/" />
14<meta property="og:site_name" content="Examined Line: The Art of Source Code Analysis with Sokrates" />
15<script type="application/ld+json">
16{"url":"/book/","headline":"Examined Line: The Art of Source Code Analysis with Sokrates","name":"Examined Line: The Art of Source Code Analysis with Sokrates","description":"A collection of articles on source code analysis with Sokrates.","@type":"WebSite","@context":"https://schema.org"}</script>
16
17<!-- End Jekyll SEO tag -->
18<link rel="stylesheet" href="/book/assets/main.css"><link type="application/atom+xml" rel="alternate" href="/book/feed.xml" title="Examined Line: The Art of Source Code Analysis with Sokrates" /></head>
19<body><header class="site-header" role="banner">
20
21  <div class="wrapper"><a class="site-title" rel="author" href="/book/">Examined Line: The Art of Source Code Analysis with Sokrates</a><nav class="site-nav">
22        <input type="checkbox" id="nav-trigger" class="nav-trigger" />
23        <label for="nav-trigger">
24          <span class="menu-icon">
25            <svg viewBox="0 0 18 15" width="18px" height="15px">
26              <path d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.032C17.335,0,18,0.665,18,1.484L18,1.484z M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.032C17.335,6.031,18,6.696,18,7.516L18,7.516z M18,13.516C18,14.335,17.335,15,16.516,15H1.484 C0.665,15,0,14.335,0,13.516l0,0c0-0.82,0.665-1.483,1.484-1.483h15.032C17.335,12.031,18,12.695,18,13.516L18,13.516z"/>
27            </svg>
28          </span>
29        </label>
30
31        <div class="trigger"></div>
32      </nav></div>
33</header>
34<main class="page-content" aria-label="Content">
35      <div class="wrapper">
36        <!-- Global site tag (gtag.js) - Google Analytics -->
vendor: 64 bytes, lines 36-37
36
37<script async src="https://www.googletagmanager.com/gtag/js?id=
37UA-129891352-1
vendor: 12 bytes, line 37
37"></script>
38<script>
39    
vendor: 156 bytes, lines 39-46
39window.dataLayer = window.dataLayer || [];
40
41    function gtag() {
42        dataLayer.push(arguments);
43    }
44
45    gtag('js', new Date());
46    gtag('config', '
46UA-129891352-1
vendor: 4 bytes, line 46
46');
47</script>
47
48
49
50<div class="home"><p><img src="assets/images/sokrates/the_death_of_socrates.jpg" alt="Under the hood" /></p>
51
52<h1 style="margin-top:60px; margin-bottom: 20px; font-weight: bold">Intro</h1>
53  <ul class="post-list"><li><span class="post-meta">&nbsp;</span>
54      <table>
55        <tr>
56          <td style="width: 80px">
57            <img src="assets/images/icons/sokrates.png" style="width: 80px;">
58          </td>
59          <td>
60            <h3>
61              <a class="post-link" href="/book/philosophy">
62                Background: Sokrates Philosophy
63              </a>
64            </h3>
65            <i>"Know your code! The unexamined code is not worth maintaining." Sokrates helps you understand your code by making visible the size, complexity, and coupling of software.</i>
66          </td>
67        </tr>
68      </table>
69    </li><li><span class="post-meta">&nbsp;</span>
70      <table>
71        <tr>
72          <td style="width: 80px">
73            <img src="assets/images/icons/usage.png" style="width: 80px;">
74          </td>
75          <td>
76            <h3>
77              <a class="post-link" href="/book/usage">
78                Using Sokrates
79              </a>
80            </h3>
81            <i>You can use Sokrates in four modes: the analyze and reflect mode, the interactive explorations mode, the traffic lights mode, the software architecture documentation mode</i>
82          </td>
83        </tr>
84      </table>
85    </li><li><span class="post-meta">&nbsp;</span>
86      <table>
87        <tr>
88          <td style="width: 80px">
89            <img src="assets/images/icons/reports.png" style="width: 80px;">
90          </td>
91          <td>
92            <h3>
93              <a class="post-link" href="/book/reports">
94                Begin With the End in Mind: Sokrates Reports
95              </a>
96            </h3>
97            <i>Before we zoom into the details of Sokrates, let's first see what insights Sokrates can give you. Sokrates makes visible the size, complexity, and coupling of software. More specifically, Sokrates generates several views on your source code, describing the overall source code characteristics, duplication, components, dependencies, conditional complexity, etc.</i>
98          </td>
99        </tr>
100      </table>
101    </li><li><span class="post-meta">&nbsp;</span>
102      <table>
103        <tr>
104          <td style="width: 80px">
105            <img src="assets/images/icons/hands_on.png" style="width: 80px;">
106          </td>
107          <td>
108            <h3>
109              <a class="post-link" href="/book/hands-on">
110                Get Your Hands Dirty
111              </a>
112            </h3>
113            <i>To learn how to use Sokrates, like with any software tools or programming languages, you need to do some hands-on work. Install Sokrates, and use this to analyze your co
113de.</i>
114          </td>
115        </tr>
116      </table>
117    </li><li><h1 style="margin-top:90px; margin-bottom: 20px; font-weight: bold">Configuring and Scoping</h1><span class="post-meta">&nbsp;</span>
118      <table>
119        <tr>
120          <td style="width: 80px">
121            <img src="assets/images/icons/configuring.png" style="width: 80px;">
122          </td>
123          <td>
124            <h3>
125              <a class="post-link" href="/book/configuring">
126                Sokrates Configuration File
127              </a>
128            </h3>
129            <i>Sokrates analyses take two inputs: the actual source code, including all folders and files, and a configuration file, which describes how Sokrates should view and analyze the source code.</i>
130          </td>
131        </tr>
132      </table>
133    </li><li><span class="post-meta">&nbsp;</span>
134      <table>
135        <tr>
136          <td style="width: 80px">
137            <img src="assets/images/icons/scoping.png" style="width: 80px;">
138          </td>
139          <td>
140            <h3>
141              <a class="post-link" href="/book/scoping">
142                Scoping
143              </a>
144            </h3>
145            <i>Scoping defines which parts of source code you want to analyze in detail and which parts to ignore. The code that developers wrote manually is the most important. It contains critical content for understanding the system's unique structure, logic, and team's design decisions.</i>
146          </td>
147        </tr>
148      </table>
149    </li><li><span class="post-meta">&nbsp;</span>
150      <table>
151        <tr>
152          <td style="width: 80px">
153            <img src="assets/images/icons/logical-decomposition.png" style="width: 80px;">
154          </td>
155          <td>
156            <h3>
157              <a class="post-link" href="/book/logical-decomposition">
158                Logical Decompositions
159              </a>
160            </h3>
161            <i>Logical decomposition is a view on the organization of the main source code. In a logical decomposition, you define components and rules to include files in the components so that each file ends in exactly one component.</i>
162          </td>
163        </tr>
164      </table>
165    </li><li><span class="post-meta">&nbsp;</span>
166      <table>
167        <tr>
168          <td style="width: 80px">
169            <img src="assets/images/icons/concerns.png" style="width: 80px;">
170          </td>
171          <td>
172            <h3>
173              <a class="post-link" href="/book/concerns">
174                Concerns
175              </a>
176            </h3>
177            <i>Concerns are any aspects of a software system that can be identified thourgh patterns in code.</i>
178          </td>
179        </tr>
180      </table>
181    </li><li><h1 style="margin-top:90px; margin-bottom: 20px; font-weight: bold">Sokrates' System Analyses</h1><span class="post-meta">&nbsp;</span>
182      <table>
183        <tr>
184          <td style="width: 80px">
185            <img src="assets/images/icons/process.png" style="width: 80px;">
186          </td>
187          <td>
188            <h3>
189              <a class="post-link" href="/book/processing">
190                Sokrates Analysis Overview
191              </a>
192            </h3>
193            <i>Sokrates processes source code in multiple stages, some of which are optional. The analysis starts with scoping, continuing through an examination of individual files and units, ending with an aggregation of results and export of reports.</i>
194          </td>
195        </tr>
196      </table>
197    </li><li><span class="post-meta">&nbsp;</span>
198      <table>
199        <tr>
200          <td style="width: 80px">
201            <img src="assets/images/icons/cleaning.png" style="width: 80px;">
202          </td>
203          <td>
204            <h3>
205              <a class="post-link" href="/book/cleaning">
206                Code Cleaning
207              </a>
208            </h3>
209            <i>As the first step in its analysis, Sokrates cleans the code to simplify analyses and to improve their reliability. Cleaning includes removal of comments, empty lines, and long string constants.</i>
210          </td>
211        </tr>
212      </table>
213    </li><li><span class="post-meta">&nbsp;</span>
214      <table>
215        <tr>
216          <td style="width: 80px">
217            <img src="assets/images/icons/file-size.png" style="width: 80px;">
218          </td>
219          <td>
220            <h3>
221              <a class="post-link" href="/book/file-size">
222                File-Level Measurements: File Size
223              </a>
224            </h3>
225            <i>Sokrates measures the size of the file in lines of code, ignoring empty lines and comments.</i>
226          </td>
227        </tr>
228      </table>
229    </li><li><span class="post-meta">&nbsp;</span>
230      <table>
231        <tr>
232          <td style="width: 80px">
233            <img src="assets/images/icons/file-history.png" style="width: 80px;">
234          </td>
235          <td>
236            <h3>
237              <a class="post-link" href="/book/history">
238                File-Level Measurements: File Age Analysis
239              </a>
240            </h3>
241            <i>File history analysis takes as an input the list of dates on which source code files changes and studies these dates to understand how frequently developers have changed the files, how old the files are, and how recently developers have updated them.</i>
242          </td>
243        </tr>
244      </table>
245    </li><li><span class="post-meta">&nbsp;</span>
246      <table>
247        <tr>
248          <td style="width: 80px">
249            <img src="assets/images/icons/file-history.png" style="width: 80px;">
250          </td>
251          <td>
252            <h3>
253              <a class="post-link" href="/book/history">
254                File-Level Measurements: File Change Frequency Analysis
255              </a>
256            </h3>
257            <i>File history analysis takes as an input the list of dates on which source code files changes and studies these dates to understand how frequently developers have changed the files, how old the files are, and how recently developers have updated them.</i>
258          </td>
259        </tr>
260      </table>
261    </li><li><span class="post-meta">&nbsp;</span>
262      <table>
263        <tr>
264          <td style="width: 80px">
265            <img src="assets/images/icons/file-history.png" style="width: 80px;">
266          </td>
267          <td>
268            <h3>
269              <a class="post-link" href="/book/history">
270                File-Level Measurements: Temporal Dependencies Analysis
271              </a>
272            </h3>
273            <i>File history analysis takes as an input the list of dates on which source code files changes and studies these dates to understand how frequently developers have changed the files, how old the files are, and how recently developers have updated them.</i>
274          </td>
275        </tr>
276      </table>
277    </li><li><span class="post-meta">&nbsp;</span>
278      <table>
279        <tr>
280          <td style="width: 80px">
281            <img src="assets/images/icons/file-history.png" style="width: 80px;">
282          </td>
283          <td>
284            <h3>
285              <a class="post-link" href="/book/history">
286                File-Level Measurements: Temporal Dependencies Analysis
287              </a>
288            </h3>
289            <i>File history analysis takes as an input the list of dates on which source code files changes and studies these dates to understand how frequently developers have changed the files, how old the files are, and how recently developers have updated them.</i>
290          </td>
291        </tr>
292      </table>
293    </li><li><span class="post-meta">&nbsp;</span>
294      <table>
295        <tr>
296          <td style="width: 80px">
297            <img src="assets/images/icons/units.png" style="width: 80px;">
298          </td>
299          <td>
300            <h3>
301              <a class="post-link" href="/book/units">
302                Unit-Level Measurements
303              </a>
304            </h3>
305            <i>Depending on a language, a unit can be a method, function procedure. Sokrates measures two things about each unit: size and conditional complexity.</i>
306          </td>
307        </tr>
308      </table>
309    </li><li><span class="post-meta">&nbsp;</span>
310      <table>
311        <tr>
312          <td style="width: 80px">
313            <img src="assets/images/icons/duplication.png" style="width: 80px;">
314          </td>
315          <td>
316            <h3>
317              <a class="post-link" href="/book/duplication">
318                Duplication Analysis
319              </a>
320            </h3>
321            <i>For duplication, Sokrates look at places in code where there are six or more lines of code that are the same.</i>
322          </td>
323        </tr>
324      </table>
325    </li><li><span class="post-meta">&nbsp;</span>
326      <table>
327        <tr>
328          <td style="width: 80px">
329            <img src="assets/images/icons/dependecies-pattern.png" style="width: 80px;">
330          </td>
331          <td>
332            <h3>
333              <a class="post-link" href="/book/dependencies">
334                Finding Dependencies based on Text Patterns
335              </a>
336            </h3>
337            <i>
337Sokrates analyses dependencies through simple text patterns searches.</i>
338          </td>
339        </tr>
340      </table>
341    </li><li><span class="post-meta">&nbsp;</span>
342      <table>
343        <tr>
344          <td style="width: 80px">
345            <img src="assets/images/icons/dependencies-duplication.png" style="width: 80px;">
346          </td>
347          <td>
348            <h3>
349              <a class="post-link" href="/book/dependencies-alt">
350                Finding Dependencies through Duplication and Change History
351              </a>
352            </h3>
353            <i>Sokrates introduces two additional dependency measurements: dependency based on duplication between files and dependencies based on the history of file changes.</i>
354          </td>
355        </tr>
356      </table>
357    </li><li><span class="post-meta">&nbsp;</span>
358      <table>
359        <tr>
360          <td style="width: 80px">
361            <img src="assets/images/icons/aggregate.png" style="width: 80px;">
362          </td>
363          <td>
364            <h3>
365              <a class="post-link" href="/book/aggregation">
366                Aggregating Measurements
367              </a>
368            </h3>
369            <i>Sokrates performs aggregation at three levels: the overall project level, the file type level (based on file extension), and the logical decomposition level.</i>
370          </td>
371        </tr>
372      </table>
373    </li><li><span class="post-meta">&nbsp;</span>
374      <table>
375        <tr>
376          <td style="width: 80px">
377            <img src="assets/images/icons/metrics-table.png" style="width: 80px;">
378          </td>
379          <td>
380            <h3>
381              <a class="post-link" href="/book/metrics">
382                Metrics Table
383              </a>
384            </h3>
385            <i>The metrics table is a list of name-value pairs, a linearized list of all Sokrates aggregated measurements. Sokrates employs the metrics table to define goals and controls and in trend analyses.</i>
386          </td>
387        </tr>
388      </table>
389    </li><li><span class="post-meta">&nbsp;</span>
390      <table>
391        <tr>
392          <td style="width: 80px">
393            <img src="assets/images/icons/controls.png" style="width: 80px;">
394          </td>
395          <td>
396            <h3>
397              <a class="post-link" href="/book/controls">
398                Controls
399              </a>
400            </h3>
401            <i>In Sokrates, you can define traffic lights like controls. For each of the metrics that Sokrates measures, you can specify a monitor with the threshold and tolerance. Sokrates will then generate a report labeling each control with one of the following states. OK (green) means that the measured value is below the threshold. Tolerant (yellow) means that the measured value is above the threshold but within the tolerance range. Failed (red) means that the measured value is above the threshold and the tolerance level.</i>
402          </td>
403        </tr>
404      </table>
405    </li><li><span class="post-meta">&nbsp;</span>
406      <table>
407        <tr>
408          <td style="width: 80px">
409            <img src="assets/images/icons/trends.png" style="width: 80px;">
410          </td>
411          <td>
412            <h3>
413              <a class="post-link" href="/book/trends">
414                Trend Analysis
415              </a>
416            </h3>
417            <i>
417Trend analysis shows the difference between values measured at different times, comparing the results of the current analysis with previous reports.</i>
418          </td>
419        </tr>
420      </table>
421    </li><li><h1 style="margin-top:90px; margin-bottom: 20px; font-weight: bold">Landscape Analysis</h1><span class="post-meta">&nbsp;</span>
422      <table>
423        <tr>
424          <td style="width: 80px">
425            <img src="assets/images/icons/landscape.png" style="width: 80px;">
426          </td>
427          <td>
428            <h3>
429              <a class="post-link" href="/book/landscape">
430                Landscape Analysis Overview
431              </a>
432            </h3>
433            <i>The Sokrates landscape analysis aggregates and indexes the Sokrates project analysis reports,  providing a centralized and uniform view on multiple Sokrates projects. </i>
434          </td>
435        </tr>
436      </table>
437    </li><li><h1 style="margin-top:90px; margin-bottom: 20px; font-weight: bold">Appendixes</h1><span class="post-meta">&nbsp;</span>
438      <table>
439        <tr>
440          <td style="width: 80px">
441            <img src="assets/images/icons/regex.png" style="width: 80px;">
442          </td>
443          <td>
444            <h3>
445              <a class="post-link" href="/book/regex">
446                Appendix: Regular Expressions
447              </a>
448            </h3>
449            <i>You cannot efficiently use Sokrates if you do not know at least the basics of regular expressions. Sokrates uses regular expressions for two purposes: to filter and classify files, extract and manipulate text, name components, or identify dependencies.</i>
450          </td>
451        </tr>
452      </table>
453    </li><li><span class="post-meta">&nbsp;</span>
454      <table>
455        <tr>
456          <td style="width: 80px">
457            <img src="assets/images/icons/transformation.png" style="width: 80px;">
458          </td>
459          <td>
460            <h3>
461              <a class="post-link" href="/book/sstl">
462                Appendix: Sokrates String Transformation Language (SSTL)
463              </a>
464            </h3>
465            <i>The Sokrates String Transformation Language (SSTL) is a simple embedded programming language enabling you to transform a phrase extracted from a file path or file content into another string. You can use SSTL to define the names of components and identify dependencies among the components.</i>
466          </td>
467        </tr>
468      </table>
469    </li><li><span class="post-meta">&nbsp;</span>
470      <table>
471        <tr>
472          <td style="width: 80px">
473            <img src="assets/images/icons/install.png" style="width: 80px;">
474          </td>
475          <td>
476            <h3>
477              <a class="post-link" href="/book/install">
478                Appendix: Installation
479              </a>
480            </h3>
481            <i>You can install and run Sokrates in three ways. First, you can download the Sokrates command-line interface JAR file. Second, you can download the Sokrates Explorer JAR file. Lastly, you can build it from scratch from the Sokrates' GitHub repository.</i>
482          </td>
483        </tr>
484      </table>
485    </li><li><span class="post-meta">&nbsp;</span>
486      <table>
487        <tr>
488          <td style="width: 80px">
489            <img src="assets/images/icons/configuration-file.png" style="width: 80px;">
490          </td>
491          <td>
492            <h3>
493              <a class="post-link" href="/book/configuration">
494                Appendix: Sokrates Configuration File
495              </a>
496            </h3>
497            <i>Sokrates configuration is a JSON file. You can use create this file manually from scratch, or use the init command to generate a default file for your project.</i>
498          </td>
499        </tr>
500      </table>
501    </li><li><span class="post-meta">&nbsp;</span>
502      <table>
503        <tr>
504          <td style="width: 80px">
505            <img src="assets/images/icons/cli.png" style="width: 80px;">
506          </td>
507          <td>
508            <h3>
509              <a class="post-link" href="/book/cli">
510                Appendix: Command Line Interface (CLI)
511              </a>
512            </h3>
513            <i>Sokrates command-line interface (CLI) includes five commands: init, generateReports, updateConfig, initLandscape, and updateLandscape.</i>
514          </td>
515        </tr>
516      </table>
517    </li><li><span class="post-meta">&nbsp;</span>
518      <table>
519        <tr>
520          <td style="width: 80px">
521            <img src="assets/images/icons/explorer.png" style="width: 80px;">
522          </td>
523          <td>
524            <h3>
525              <a class="post-link" href="/book/explorer">
526                Appendix: Sokrates Explorer
527              </a>
528            </h3>
529            <i>Sokrates Explorer centralizes configuration, running of commands, and preview of analysis results in one tool. Explorer has a graphical user interface with a configuration editor, code preview panels, and several additional features that facilitate free exploration of code. With Explorer, you can almost instantly see how a change in a setting, e.g., adding a new rule for detecting test files, impacts the analysis results.</i>
530          </td>
531        </tr>
532      </table>
533    </li></ul>
534
535  <p class="feed-subscribe">
536    <a href="/book/feed.xml">
537      <svg class="svg-icon orange">
538        <use xlink:href="/book/assets/minima-social-icons.svg#rss"></use>
539      </svg>
540      <span>Subscribe</span>
541    </a>
542  </p></div>
543
544      </div>
545    </main><footer class="site-footer h-card">
546  <data class="u-url" href="/book/"></data>
547
548  <div class="wrapper">
549
550    <h2 class="footer-heading">Examined Line: The Art of Source Code Analysis with Sokrates</h2>
551
552    <div class="footer-col-wrapper">
553      <div class="footer-col footer-col-1">
554        <ul class="contact-list">
555          <li class="p-name">Examined Line: The Art of Source Code Analysis with Sokrates</li><li><a class="u-email" href="mailto:[email protected]">[email protected]</a></li></ul>
556      </div>
557
558      <div class="footer-col footer-col-2"><ul class="social-media-list"><li><a href="https://github.com/zeljkoobrenovic"><svg class="svg-icon"><use xlink:href="/book/assets/minima-social-icons.svg#github"></use></svg> <span class="username">zeljkoobrenovic</span></a></li><li><a href="https://www.linkedin.com/in/zeljkoobrenovic"><svg class="svg-icon"><use xlink:href="/book/assets/minima-social-icons.svg#linkedin"></use></svg> <span class="username">zeljkoobrenovic</span></a></li><li><a href="https://www.twitter.com/zeljko_obren"><svg class="svg-icon"><use xlink:href="/book/assets/minima-social-icons.svg#twitter"></use></svg> <span class="username">zeljko_obren</span></a></li></ul>
559</div>
560
561      <div class="footer-col footer-col-3">
562        <p>A collection of articles on source code analysis with Sokrates.</p>
563      </div>
564    </div>
565
566  </div>
567
568</footer>
569</body>
570
571</html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.