The ns-3 Network Simulator Project

Codebase line length survey

One loosely enforced rule is the ns-3 codebase is maximum line length. We have informally recommended a maximum of 128 columns, although it isn't mentioned in our coding style document: https://www.nsnam.org/develop/contributing-code/coding-style/.

For this task, we request the author to write and submit a Python program that does the following:

  1. Allows the user to declare a maximum line length as a constant integer (such as 128).

  2. Finds all C++ files (suffixed by .cc or .h) in the current directory, and recursively, any subdirectories. When run from the top-level directory of our main repository (ns-3-dev), it should find around 2500 files.

  3. Examines each line (code or comment) of each file to check if the line length exceeds the maximum line length.

  4. If no files are found with a line greater than the maximum line length, the program should exit cleanly with no output, and with a return error code of zero. If one or more files are found with a line greater than the maximum line length, the program should list to standard output (one file per line) the non-conforming files and should return an error exit code of 1.

    • As a bonus (not required), consider to list out the line numbers that do not conform, such as (if, for instance, lines 29, 64, and 88 did not conform): examples/tutorials/first.cc: 29, 64, 88
  5. We may wish to exclude some files from checking. Provide a means for listing one or more such file exclusions within the program.

Students who completed this task

InquisitivePenguin

Task type

  • done_all Quality Assurance

Level

Beginner
close

2019