Amount of bugs per 1,000 lines of code.
N/A
The number of bugs divided by the total accumulated lines of code (additions + deletions) in the given data range.
Data sources required
issues collected from Jira, GitHub or TAPD.commits collected from GitHub, GitLab or BitBucket.Data Transformation Required
This metric relies on the ‘type-bug’ configuration in Jira, GitHub or TAPD's transformation rules while adding/editing a blueprint. This configuration tells DevLake what issues are bugs.
SQL Queries
If you want to measure the monthly trend of Bugs per 1k lines of code in the screenshot below, please run the following SQL in Grafana.
with _line_of_code as (
select
DATE_ADD(date(authored_date), INTERVAL -DAY(date(authored_date))+1 DAY) as time,
sum(additions + deletions) as line_count
from
commits
where
message not like 'Merge%'
and $__timeFilter(authored_date)
group by 1
),
_bug_count as(
select
DATE_ADD(date(created_date), INTERVAL -DAY(date(created_date))+1 DAY) as time,
count(*) as bug_count
from issues i
where
type = 'Bug'
and $__timeFilter(created_date)
group by 1
),
_bug_count_per_1k_loc as(
select
loc.time,
1.0 * bc.bug_count / loc.line_count * 1000 as bug_count_per_1k_loc
from
_line_of_code loc
left join _bug_count bc on bc.time = loc.time
where
bc.bug_count is not null
and loc.line_count is not null
and loc.line_count != 0
)
select
date_format(time,'%M %Y') as month,
bug_count_per_1k_loc as 'Bug Count per 1000 Lines of Code'
from _bug_count_per_1k_loc
order by time;