Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox source code analysis; lines of code per component

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.

like image 591
Fraser Price Avatar asked Jul 03 '17 18:07

Fraser Price


People also ask

How many lines of code is Firefox?

Many setups and CI platforms are available for developers. Firefox is a vast (21M lines of code) open source software project which grew from Netscape in 1998.

Is Firefox a source code?

Firefox is an open source project; much of the code is contributed by our huge community of volunteers. Here you can learn about how to contribute to the Firefox project and you will also find links to information about the construction of Firefox add-ons, using the developer tools in Firefox, and other topics.

What language is Firefox built in?

C++ and JavaScript JavaScript is most commonly known as a technology used to implement web sites. However, the developers of Mozilla decided that the Mozilla source code itself should consist of a mixture of both languages. When you start the application, the C/C++ components start first.

How do I contribute to Firefox code?

To make a technical contribution:Contribute to the Mozilla code base -> [1] Find your first code contribution -> codetribute.mozilla.org. Contribute documentation to the Mozilla Developer Network -> developer.mozilla.org. Contribute your design to an open design community -> github.com/mozilla/OpenDesign/


1 Answers

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.

like image 53
Dexter Avatar answered Oct 31 '22 17:10

Dexter