dart_class_analyzer

Creator: coderz1093

Last updated:

0 purchases

dart_class_analyzer Image
dart_class_analyzer Images

Languages

Categories

Add to Cart

Description:

dart class analyzer

Dart Class Analyzer #



Dart Class Analyzer is a Dart package that provides tools for analyzing Dart classes and methods in a project. It helps you understand the structure of your codebase by counting methods in classes and provides insights into your project's organization.
Table of Contents #

Introduction
Installation

Install it as a CLI
Install it as a library


Usage

Use it as a CLI
Use it as a library

Count Methods in Folder
Count Methods in Class
Analyze Class




Continuous Integration
Running Tests
Contributing
License

Installation ๐Ÿ’ป #
โ— In order to start using Dart Class Analyzer, you must have the Dart SDK installed on your machine.
Install it as a CLI #
Activate the package with:
dart pub global activate dart_class_analyzer
copied to clipboard
Install it as a library #
Install via dart pub add:
dart pub add dart_class_analyzer
copied to clipboard

Usage #
Use it as a CLI
Count the methods in a project with:
dart pub global run dart_class_analyzer:method_counter [options] <project_lib_path>
copied to clipboard
CLI Options:


-v If provided, analyzer will output all files and their method counts.


-g If provided, analyzer will include generated .g.dart files in the analysis.


-h If provided, analyzer will display usage help.


Use it as an library

Import the dart_class_analyzer package.

import 'package:dart_class_analyzer/dart_class_analyzer.dart';
copied to clipboard

Create an instance of DartClassAnalyzer.

final analyzer = DartClassAnalyzer();
copied to clipboard
Count Methods in Folder
Use the countMethodsInFolder method to analyze Dart files in a folder.
final pathToDartFiles = 'path/to/your/dart/files';
final classes = analyzer.countMethodsInFolder(pathToDartFiles);

for (final classModel in classes) {
print('${classModel.className} has ${classModel.methodCount} methods');
}
copied to clipboard
This will print information about each class in the specified folder, including the class name and the number of methods it has.
Remember to replace 'path/to/your/dart/files' with the actual path to your Dart files, and adjust the code examples based on your project structure.
Count Methods in Class
Use countMethodsInClass to analyze a single Dart class represented by code.
final dartCode = '''
class MyClass {
void method1() {}
void method2() {}
}
''';

final classModel = analyzer.countMethodsInClass(dartCode);

if (classModel != null) {
print('${classModel.className} has ${classModel.methodCount} methods');
}
copied to clipboard
This will print information about the specified class.
Analyze Class
If you have a Dart class and want to analyze its methods using reflection, you can use the analyzeClass method.
class MyClass {
void method1() {}
void method2() {}
}

final methodCount = analyzer.analyzeClass(MyClass);
print('MyClass has $methodCount methods');
copied to clipboard
This will print the total number of methods in the specified class.
Continuous Integration ๐Ÿค– #
Dart Class Analyzer comes with a built-in GitHub Actions workflow powered by [Very Good Workflows][very_good_workflows_link]. You can also integrate it with your preferred CI/CD solution.
On each pull request and push, the CI pipeline performs code formatting, linting, and testing to ensure code consistency and correctness. The project adheres to Very Good Analysis for strict analysis options. Code coverage is monitored using Very Good Coverage.

Running Tests ๐Ÿงช #
To run all unit tests:
dart pub global activate coverage 1.2.0
dart test --coverage=coverage
dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info
copied to clipboard
To view the generated coverage report, you can use lcov.
# Generate Coverage Report
genhtml coverage/lcov.info -o coverage/

# Open Coverage Report
open coverage/index.html
copied to clipboard
Contributing #
If you would like to contribute to the project, follow these steps:

Fork the project.
Create your feature branch (git checkout -b feature/YourFeature).
Commit your changes (git commit -m 'Add some feature').
Push to the branch (git push origin feature/YourFeature).
Open a pull request.

License #
This project is licensed under the MIT License - see the LICENSE file for details.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.