dedupe 0.1.0 copy "dedupe: ^0.1.0" to clipboard
dedupe: ^0.1.0 copied to clipboard

High-performance code duplication and clone detection engine and CLI tool for Dart and Flutter.

example/example.dart

import 'package:dedupe/dedupe.dart';

void main() async {
  // Configure analysis options.
  final options = DedupeOptions(
    targetPath: '.',
    minTokens: 30,
    minLines: 4,
    ignoreComments: true,
    ignoreLiterals: true,
    ignoreIdentifiers: false,
  );

  // Initialize the deduplication engine and run the analysis.
  final engine = DedupeEngine(options);
  final report = await engine.analyze();

  // Inspect aggregate summary metrics.
  final summary = report.summary;
  print('Deduplication Analysis Summary:');
  print('  Files analyzed: ${summary.filesAnalyzed}');
  print('  Total lines: ${summary.totalLines}');
  print('  Duplicate lines: ${summary.duplicateLines}');
  print(
    '  Duplication rate: '
    '${summary.duplicationPercentage.toStringAsFixed(1)}%',
  );
  print('  Duplicate clusters found: ${summary.clusterCount}');
  print('  Estimated lines saved: ${summary.estimatedLinesSaved}');

  // Inspect individual duplicate clusters.
  if (report.clusters.isNotEmpty) {
    print('\nDetected Duplicate Clusters:');
    for (final cluster in report.clusters) {
      print(
        '  [Cluster ${cluster.id}] '
        '${cluster.category.displayName} (${cluster.bucket.displayName}):',
      );
      print(
        '    Instances: ${cluster.instanceCount}, '
        'Lines: ${cluster.lineCount}, '
        'Tokens: ${cluster.tokenCount}',
      );
      for (final instance in cluster.instances) {
        print(
          '      - ${instance.filePath}:'
          '${instance.startLine}-${instance.endLine}',
        );
      }
    }
  } else {
    print('\nNo duplicate code clusters detected.');
  }
}
0
likes
160
points
105
downloads

Documentation

API reference

Publisher

verified publisherkevmoo.com

Weekly Downloads

High-performance code duplication and clone detection engine and CLI tool for Dart and Flutter.

Repository (GitHub)
View/report issues

Topics

#static-analysis #code-quality #linter #cli

License

MIT (license)

Dependencies

analytica, analyzer, args, io, path

More

Packages that depend on dedupe