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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0b5ec6cb7d308ddcbdaffd0be5a523705439d2e34b4e4fcfe1735f15f5141c4
4
- data.tar.gz: d10a22a734a413ffd11f891252596ed69a870f57aadb4832c7fef9e0c73cdb0c
3
+ metadata.gz: ec9c180b994b4c6cefec35a05422f1f42f9b1dd93c3df6e1d645ed6b03207e0a
4
+ data.tar.gz: 001c96313356478f3d97ec63e8602ef9645e53885b664588cb70d00562d7d23c
5
5
  SHA512:
6
- metadata.gz: 610ccdf77eebbcc63f26aa05190fae5977e3798d0b6f99c81b659f7ed6fede90cf541286a5505b8d651e6a58602c59a02c9fba74922f3675d963725ee7380a75
7
- data.tar.gz: a91a2ce7050c523a00357d78f91e5981d3c7740734e992348e1a6607b92d9f232ea5e61f8e74fbe6fa8659742bddb3579057d2665651dcae96da6c0f9f351624
6
+ metadata.gz: 1a1d834fa4643dc34c840a95d8205a83fd51659cd9721537b802fb9b6cbf879da74ff7c1693ab0804dbd52258a77eedb9e0283fdf0ec916e28dc1d6be0cde02e
7
+ data.tar.gz: 06f0118bba2fdcd2bc0149fee55854c443da98c21cbdb8d732e617980c1702eccbd9403aaf833282f18adc86695e2ffb4a5b2e366942a41c921323a60bc9f3e2
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- # Copyright (c) 2019-2020 Yegor Bugayenko
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.1.2'
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
- values = values.map { |v| (v - min).to_f / (max - min) }
75
- mu = values.inject(&:+) / values.count
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 = values.map { |v| (v - mu)**2 }.inject(&:+).to_f / values.count
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
@@ -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 $i$ out of $N$ was touched
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, $t$ that relate to the files already absent in the
54
- repository are deleted and the array $T$ is ``normalized''
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{eqnarray}
58
- X = [x_1, x_2, \dots, x_M],\quad \text{where}\ x_i = \frac{t_i - \hat{T}}{\check{T} - \hat{T}}
59
- \end{eqnarray}
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}{M}\sum{x_i}
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(x) = \frac{1}{M}\sum{|x_i - \mu|^2}
72
+ Var(g) = \frac{1}{Z}\sum_{j=1}^{Z}{|g_j - \mu|^2}
71
73
  \end{eqnarray}
72
74
 
73
- The variance $Var(x)$ is the volatility of the source code. The smaller
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
 
@@ -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.1.2'
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'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volatility
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko