dark-lines-of-code-analyzer

DarkLinesOfCodeAnalyzer

A simple Roslyn analyzer that checks the amount of lines of code in your files and shows a warning if there are too many.

Rule of 30
This analyzer makes use of the “Rule of 30” in Refactoring in Large Software Projects by Martin Lippert and Stephen Roock:

  1. Methods should not have more than an average of 30 code lines (not counting line spaces and comments).
  2. A class should contain an average of less than 30 methods, resulting in up to 900 lines of code.
  3. A package shouldn’t contain more than 30 classes, thus comprising up to 27,000 code lines.
  4. Subsystems with more than 30 packages should be avoided. Such a subsystem would count up to 900 classes with up to 810,000 lines of code.
  5. A system with 30 subsystems would thus possess 27,000 classes and 24.3 million code lines.

Nuget

nuget nuget

PM> Install-Package Divis.DarkLinesOfCodeAnalyzer

Roadmap

Here’s the planned feature roadmap:

Feature Status
max 900 lines per class
max 30 lines per method
ignore blank lines 🔲

Example

The resulting warning might look like this:

> C:\Projects\demo-app\DemoConsoleApp\WeatherService.cs(5,5,1078,6): warning DL0100: The class 'WeatherService' contains 1076 lines of code, maximum recommended amount of lines per class is 900 lines
> C:\Projects\demo-app\DemoConsoleApp\WeatherService.cs(8,9,1077,10): warning DL0200: The method 'GetForecastForCity' contains 48 lines of code, maximum recommended amount of lines per method is 30 lines
Visit original content creator repository https://github.com/michaldivis/dark-lines-of-code-analyzer

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *