@@ -68,7 +68,7 @@ class CodeLine(val repo: Repository,
6868 * The code line's age in seconds.
6969 */
7070 val age : Long
71- get() = (to.commit.getCommitTime() - from.commit.getCommitTime() ).toLong()
71+ get() = (to.commit.commitTime - from.commit.commitTime ).toLong()
7272
7373 /* *
7474 * The code line text.
@@ -109,7 +109,7 @@ class CodeLine(val repo: Repository,
109109class CodeLongevity (private val localRepo : LocalRepo ,
110110 private val serverRepo : Repo ,
111111 private val api : Api ,
112- private val git : Git ) {
112+ git : Git ) {
113113 val repo: Repository = git.repository
114114 val head: RevCommit =
115115 RevWalk (repo).parseCommit(repo.resolve(RepoHelper .MASTER_BRANCH ))
@@ -129,7 +129,7 @@ class CodeLongevity(private val localRepo: LocalRepo,
129129 val totals: MutableMap <String , Int > = emails.associate { Pair (it, 0 ) }
130130 .toMutableMap()
131131
132- var repoTotal: Int = 0
132+ var repoTotal = 0
133133 var repoSum: Long = 0
134134 getLinesObservable().blockingSubscribe { line ->
135135 repoTotal++
@@ -207,7 +207,7 @@ class CodeLongevity(private val localRepo: LocalRepo,
207207 val fileLoader = repo.open(fileId)
208208 if (! RawText .isBinary(fileLoader.openStream())) {
209209 val fileText = RawText (fileLoader.getBytes())
210- var lines = ArrayList <RevCommitLine >(fileText.size())
210+ val lines = ArrayList <RevCommitLine >(fileText.size())
211211 for (idx in 0 .. fileText.size() - 1 ) {
212212 lines.add(RevCommitLine (head, fileId, path, idx, false ))
213213 }
@@ -226,7 +226,7 @@ class CodeLongevity(private val localRepo: LocalRepo,
226226 Logger .debug(" old: '$oldPath ', new: '$newPath '" )
227227
228228 // Skip binary files.
229- var fileId = if (newPath != DiffEntry .DEV_NULL ) newId else oldId
229+ val fileId = if (newPath != DiffEntry .DEV_NULL ) newId else oldId
230230 if (RawText .isBinary(repo.open(fileId).openStream())) {
231231 continue
232232 }
@@ -240,8 +240,7 @@ class CodeLongevity(private val localRepo: LocalRepo,
240240 if (diff.changeType == DiffEntry .ChangeType .DELETE ) {
241241 val fileLoader = repo.open(oldId)
242242 val fileText = RawText (fileLoader.getBytes())
243- files.put(oldPath,
244- ArrayList <RevCommitLine >(fileText.size()))
243+ files.put(oldPath, ArrayList (fileText.size()))
245244 }
246245
247246 // If a file was deleted, then the new path is /dev/null.
@@ -260,16 +259,16 @@ class CodeLongevity(private val localRepo: LocalRepo,
260259 // Insertion case: track the lines.
261260 val insCount = edit.getLengthB()
262261 if (insCount > 0 ) {
263- var insStart = edit.getBeginB()
264- var insEnd = edit.getEndB()
262+ val insStart = edit.getBeginB()
263+ val insEnd = edit.getEndB()
265264 Logger .debug(" ins ($insStart , $insEnd )" )
266265
267266 for (idx in insStart .. insEnd - 1 ) {
268267 val from = RevCommitLine (commit, newId,
269268 newPath, idx, false )
270- var to = lines.get(idx)
269+ val to = lines.get(idx)
271270 val cl = CodeLine (repo, from, to)
272- Logger .debug(" Collected: ${cl.toString() } " )
271+ Logger .debug(" Collected: ${cl} " )
273272 subscriber.onNext(cl)
274273 }
275274 lines.subList(insStart, insEnd).clear()
@@ -286,7 +285,7 @@ class CodeLongevity(private val localRepo: LocalRepo,
286285 val delEnd = edit.getEndA()
287286 Logger .debug(" del ($delStart , $delEnd )" )
288287
289- var tmpLines = ArrayList <RevCommitLine >(delCount)
288+ val tmpLines = ArrayList <RevCommitLine >(delCount)
290289 for (idx in delStart .. delEnd - 1 ) {
291290 tmpLines.add(RevCommitLine (commit, oldId,
292291 oldPath, idx, true ))
@@ -320,7 +319,7 @@ class CodeLongevity(private val localRepo: LocalRepo,
320319 val from = RevCommitLine (tail, fileId,
321320 filePath, idx, false )
322321 val cl = CodeLine (repo, from, lines[idx])
323- Logger .debug(" Collected (tail): ${cl.toString()} " )
322+ Logger .debug(" Collected (tail): $cl " )
324323 subscriber.onNext(cl)
325324 }
326325 }
@@ -340,7 +339,7 @@ class CodeLongevity(private val localRepo: LocalRepo,
340339 val revWalk = RevWalk (repo)
341340 revWalk.markStart(head)
342341
343- var commit: RevCommit ? = revWalk.next() // move the walker to the head
342+ var commit: RevCommit ? = revWalk.next() // Move the walker to the head.
344343 while (commit != null && commit != tail) {
345344 val parentCommit: RevCommit ? = revWalk.next()
346345
0 commit comments