Skip to content

Commit 1526843

Browse files
authored
Update README.md
1 parent 8baf3a7 commit 1526843

1 file changed

Lines changed: 7 additions & 29 deletions

File tree

README.md

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -188,67 +188,45 @@ VariableHardUsage is an index used to evaluate the frequency of use and scope of
188188

189189
This tool calculates the **Variable Hard Usage** score for each **scope** (i.e., a function or method) based on how local variables are used. The calculation consists of the following steps:
190190

191-
---
192-
193191
#### 1. Extract local variables in a scope
194192

195193
For each scope $S$, extract all local variables:
196194

197-
$$
198-
V = {v_1, v_2, ..., v_m}
199-
$$
200-
201-
---
195+
$V = {v_1, v_2, ..., v_m}$
202196

203197
#### 2. For each variable $v_j$, identify lines where it is referenced
204198

205199
Let the variable $v_j$ be referenced at line numbers:
206200

207-
$$
208-
L^{(j)} = {l^{(j)}_1, l^{(j)}_2, ..., l^{(j)}_{n_j}} \quad \text{(sorted in ascending order)}
209-
$$
210-
211-
---
201+
$`L^{(j)} = {l^{(j)}_1, l^{(j)}_2, ..., l^{(j)}_{n_j}} \quad`$
212202

213203
#### 3. Assign weights to each reference
214204

215205
Each reference line $l^{(j)}_i$ is assigned a weight $w^{(j)}_i$ depending on whether it is a simple read or an assignment:
216206

217207
- If the reference is **an assignment (update)**:
218-
$$
219-
w^{(j)}_i = \alpha \quad (\text{default: } \alpha = 2)
220-
$$
208+
$`w^{(j)}_i = \alpha \quad (\text{default: } \alpha = 2)`$
221209

222210
- If the reference is **a read-only access**:
223-
$$
224-
w^{(j)}_i = 1
225-
$$
226-
227-
---
211+
$`w^{(j)}_i = 1`$
228212

229213
#### 4. Calculate Variable Hard Usage for each variable
230214

231215
Let $l^{(j)}_\text{base} = l^{(j)}_1$, the first line where $v_j$ appears.
232216

233217
Then, the hard usage score for $v_j$ is calculated as:
234218

235-
$$
236-
H(v_j) = \sum_{i=1}^{n_j} w^{(j)}_i \cdot |l^{(j)}_i - l^{(j)}_\text{base}|
237-
$$
219+
$`H(v_j) = \sum_{i=1}^{n_j} w^{(j)}_i \cdot |l^{(j)}_i - l^{(j)}_\text{base}|`$
238220

239221
This measures how widely and intensely the variable is used, with updates having a stronger impact.
240222

241-
---
242-
243223
#### 5. Sum all variable scores to get the score for the scope
244224

245225
The total **Variable Hard Usage** for the scope $S$ is:
246226

247-
$$
248-
H(S) = \sum_{j=1}^{m} H(v_j) = \sum_{j=1}^{m} \sum_{i=1}^{n_j} w^{(j)}_i \cdot |l^{(j)}_i - l^{(j)}_\text{base}|
249-
$$
227+
$`H(S) = \sum_{j=1}^{m} H(v_j) = \sum_{j=1}^{m} \sum_{i=1}^{n_j} w^{(j)}_i \cdot |l^{(j)}_i - l^{(j)}_\text{base}|`$
250228

251-
A larger value of $H(S)$ indicates that variables in the scope are heavily and broadly used, which may reduce code readability and maintainability.
229+
A larger value of $`H(S)`$ indicates that variables in the scope are heavily and broadly used, which may reduce code readability and maintainability.
252230

253231
### Example
254232

0 commit comments

Comments
 (0)