volatility 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/volatility +10 -5
- data/features/cli.feature +6 -2
- data/theory.pdf +0 -0
- data/theory.tex +13 -11
- data/volatility.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec9c180b994b4c6cefec35a05422f1f42f9b1dd93c3df6e1d645ed6b03207e0a
|
4
|
+
data.tar.gz: 001c96313356478f3d97ec63e8602ef9645e53885b664588cb70d00562d7d23c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a1d834fa4643dc34c840a95d8205a83fd51659cd9721537b802fb9b6cbf879da74ff7c1693ab0804dbd52258a77eedb9e0283fdf0ec916e28dc1d6be0cde02e
|
7
|
+
data.tar.gz: 06f0118bba2fdcd2bc0149fee55854c443da98c21cbdb8d732e617980c1702eccbd9403aaf833282f18adc86695e2ffb4a5b2e366942a41c921323a60bc9f3e2
|
data/bin/volatility
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
# Copyright (c)
|
4
|
+
# Copyright (c) 2012-2020 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -23,7 +23,7 @@
|
|
23
23
|
|
24
24
|
STDOUT.sync = true
|
25
25
|
|
26
|
-
VERSION = '0.
|
26
|
+
VERSION = '0.2.0'
|
27
27
|
|
28
28
|
require 'slop'
|
29
29
|
require 'backtrace'
|
@@ -42,6 +42,7 @@ Options are:"
|
|
42
42
|
o.bool '--verbose', 'Print all details' do
|
43
43
|
$verbose = true
|
44
44
|
end
|
45
|
+
o.integer '--sectors', 'Total sectors to use', default: 64
|
45
46
|
o.string '--home',
|
46
47
|
'The path to the repository (current dir by default)',
|
47
48
|
default: '.'
|
@@ -71,10 +72,14 @@ Options are:"
|
|
71
72
|
put "Min = #{min}"
|
72
73
|
max = values.max
|
73
74
|
put "Max = #{max}"
|
74
|
-
|
75
|
-
|
75
|
+
delta = (max - min) / opts[:sectors]
|
76
|
+
delta = 1 if delta.zero?
|
77
|
+
put "D = #{delta}"
|
78
|
+
s = values.group_by { |v| (v - min) / delta }.values.map(&:count).sort.reverse
|
79
|
+
put "S = #{s}"
|
80
|
+
mu = s.inject(&:+) / s.count
|
76
81
|
put "µ = #{mu}"
|
77
|
-
var =
|
82
|
+
var = s.map { |v| (v - mu)**2 }.inject(&:+).to_f / s.count
|
78
83
|
put "Var(X) = #{var}"
|
79
84
|
puts format('%.8f', var)
|
80
85
|
rescue StandardError => ex
|
data/features/cli.feature
CHANGED
@@ -9,11 +9,15 @@ Feature: Command Line Processing
|
|
9
9
|
Scenario: Volatility can be calculated
|
10
10
|
When I run bash with:
|
11
11
|
"""
|
12
|
-
git config --global user.name "NoName"
|
13
|
-
git config --global user.email "noname@example.com"
|
14
12
|
mkdir tmp
|
15
13
|
cd tmp
|
16
14
|
git init .
|
15
|
+
if git config user.email; then
|
16
|
+
echo Git email already set
|
17
|
+
else
|
18
|
+
git config user.name "NoName"
|
19
|
+
git config user.email "noname@example.com"
|
20
|
+
fi
|
17
21
|
touch test.txt
|
18
22
|
git add test.txt
|
19
23
|
git commit -am 'test'
|
data/theory.pdf
CHANGED
Binary file
|
data/theory.tex
CHANGED
@@ -43,34 +43,36 @@ an indicator of maintainability problems in the project.
|
|
43
43
|
\section{Details}
|
44
44
|
|
45
45
|
First, by looking at Git history,
|
46
|
-
it is observed how many times every source code file
|
47
|
-
during the lifetime of the repository
|
46
|
+
it is observed how many times every source code file out of $N$ was touched
|
47
|
+
during the lifetime of the repository (excluding the files that don't exist
|
48
|
+
in the repository anymore):
|
48
49
|
|
49
50
|
\begin{eqnarray}
|
50
51
|
T = [t_1, t_2, \dots, t_N]
|
51
52
|
\end{eqnarray}
|
52
53
|
|
53
|
-
Then,
|
54
|
-
|
55
|
-
to keep all values within the $[0,1]$ range:
|
54
|
+
Then, the entire interval between $\check{T}$ (the maximum value)
|
55
|
+
and $\hat{T}$ (the minimum value) is divided to $Z$ equivalent groups:
|
56
56
|
|
57
|
-
\begin{
|
58
|
-
|
59
|
-
\
|
57
|
+
\begin{align}
|
58
|
+
G &= [g_1, g_2, \dots, g_{Z}] \\
|
59
|
+
\delta &= ( \check{T} - \hat{T} ) / Z \\
|
60
|
+
g_j &= \sum_{i=1}^N [ j(\delta-1) < t_i < j\delta ]
|
61
|
+
\end{align}
|
60
62
|
|
61
63
|
Then, the mean $\mu$ is calculated as:
|
62
64
|
|
63
65
|
\begin{eqnarray}
|
64
|
-
\mu = \frac{1}{
|
66
|
+
\mu = \frac{1}{Z}\sum_{j=1}^{Z}{g_j}
|
65
67
|
\end{eqnarray}
|
66
68
|
|
67
69
|
Finally, the variance is calculated as:
|
68
70
|
|
69
71
|
\begin{eqnarray}
|
70
|
-
Var(
|
72
|
+
Var(g) = \frac{1}{Z}\sum_{j=1}^{Z}{|g_j - \mu|^2}
|
71
73
|
\end{eqnarray}
|
72
74
|
|
73
|
-
The variance $Var(
|
75
|
+
The variance $Var(g)$ is the volatility of the source code. The smaller
|
74
76
|
the volatility the more cohesive is the repository and the smaller
|
75
77
|
the amount of the dead code inside it.
|
76
78
|
|
data/volatility.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.rubygems_version = '2.2'
|
33
33
|
s.required_ruby_version = '>= 2.3'
|
34
34
|
s.name = 'volatility'
|
35
|
-
s.version = '0.
|
35
|
+
s.version = '0.2.0'
|
36
36
|
s.license = 'MIT'
|
37
37
|
s.summary = 'Source Code Volatility'
|
38
38
|
s.description = 'The command line tool calculates the SCV metric for a Git repo'
|