Firefox source code analysis; lines of code per component
Asked Answered
G

1

8

I am currently trying to analyse Bugzilla in order to find the ratio of number of bugs : lines of code for each Firefox component. However, I have never worked with Bugzilla before and have no knowledge of Firefox's codebase.

How would I go about finding lines of code per Firefox component (as they appear on Bugzilla under Comp header)? I have made an attempt at looking through mozilla central, but have no idea which source files relate to which components.

EDIT: Dexter pointed out that there is a directive BUG_COMPONENT in the mozilla-central tree, but this directive seems extremely incomplete and is not helpful. Any other advice, or pointers as to where I could get such advice would be much appreciated.

Gagliano answered 3/7, 2017 at 18:25 Comment(0)
H
7

Great question! We recently added the BUG_COMPONENT directive (see the meta bug) to the Firefox code: it's in the moz.build file contained in each directory in the source. This directive allows linking each file in the repository to the related Bugzilla component.

For example, the following directive found here, tells that all the files in test/browser containing the Telemetry word belong to the Toolkit::Telemetry component on Bugzilla.

with Files("test/browser/*Telemetry*"):
    BUG_COMPONENT = ("Toolkit", "Telemetry")

You can use either DXR or searchfox to quickly search the Firefox repository.

Updated the answer to account for the questions in the comments.

As noted in the comments, some components are tracked on Bugzilla (e.g. Activity Stream) but do not have a direct mapping to source files within the mozilla-central repository (the one Firefox is built from). That's because some newer components do not ride "the trains" (~6 weeks development cycle), but are rather updated more frequently and deployed as addons.

The code for these components usually lives under the Mozilla github account, along with other project. Since there are quite a number of projects, one way to identify the ones you might be interested in is to restrict them to JavaScript ones. If you follow this last link, you'll see the repository for both the test-pilot and Activity Stream (plus other addons).

I'm afraid the only way to match GitHub projects to Bugzilla components is to look at the name of the repository on GitHub and find the matching component in Bugzilla: you can type the name here to get some component suggestions. If you want to get fancy, you might also leverage the Bugzilla REST API:

  1. Get a list of the JS GitHub project.
  2. Extract the name of the project.
  3. Use the REST API to get the component suggestion.

I would personally just consider the mozilla-central repository as a starting point, as it is mostly annotated: scrape the BUG_COMPONENT from the source files, map them to the paths then use the REST API to get the list of bugs.

Sidenote: the Download Panel seems to be correctly annotated in the main repo.

Hove answered 4/7, 2017 at 7:53 Comment(6)
Perfect, just what I was looking for. Thanks a lot!Gagliano
I've noticed some Firefox components (e.g. Activity Streams, Downloads Panel, Extension Compatability, etc.) do not appear to be indexed. Is there a reason for this, or is BUG_COMPONENT directive not yet complete? Query: dxr.mozilla.org/mozilla-central/…Gagliano
Some of the things you mentioned live outside of the main mozilla repository. They are stored in their own github repository, e.g. Activity Stream lives hereHove
OK; I'm guessing if I wanted to cover all components + source it may take a lot more effort then. Could you maybe point me in the right direction if I wanted to achieve something like this (e.g. other obvious repos, any other component -> src mappings, or general tips)? Thanks for your help so far, it's very much appreciated.Gagliano
I've just updated my answer to address your questions, I hope I've covered all the points!Hove
Thanks a lot. I don't think I'm going to be able to achieve what I set out to do, but you've been a great help!Gagliano

© 2022 - 2024 — McMap. All rights reserved.