Future analyze()

in app/lib/fake/backend/fake_pana_runner.dart [23:96]


  Future<Summary> analyze({
    required String package,
    required String version,
    required PackageStatus packageStatus,
  }) async {
    final random = Random('$package/$version'.hashCode);
    final layoutPoints = random.nextInt(30);
    final examplePoints = random.nextInt(30);
    final hasSdkDart = random.nextInt(10) > 0;
    final hasSdkFlutter =
        random.nextInt(packageStatus.usesFlutter ? 20 : 10) > 0;
    final hasValidSdk = hasSdkDart || hasSdkFlutter;
    return Summary(
      packageName: package,
      packageVersion: Version.parse(version),
      runtimeInfo: PanaRuntimeInfo(
        sdkVersion: packageStatus.usesPreviewAnalysisSdk
            ? toolPreviewDartSdkVersion
            : toolStableDartSdkVersion,
        panaVersion: panaVersion,
        flutterVersions: {},
      ),
      allDependencies: <String>[],
      tags: <String>[
        if (hasSdkDart) 'sdk:dart',
        if (hasSdkDart && random.nextInt(5) > 0) 'runtime:native-aot',
        if (hasSdkDart && random.nextInt(5) > 0) 'runtime:native-jit',
        if (hasSdkDart && random.nextInt(5) > 0) 'runtime:web',
        if (hasSdkFlutter) 'sdk:flutter',
        if (hasValidSdk && random.nextInt(5) > 0) 'platform:android',
        if (hasValidSdk && random.nextInt(5) > 0) 'platform:ios',
        if (hasValidSdk && random.nextInt(5) > 0) 'platform:linux',
        if (hasValidSdk && random.nextInt(5) > 0) 'platform:macos',
        if (hasValidSdk && random.nextInt(5) > 0) 'platform:web',
        if (hasValidSdk && random.nextInt(5) > 0) 'platform:windows',
      ],
      report: Report(
        sections: [
          ReportSection(
            id: ReportSectionId.convention,
            title: 'Fake conventions',
            grantedPoints: layoutPoints,
            maxPoints: 30,
            summary: renderSimpleSectionSummary(
              title: 'Package layout',
              description:
                  'Package layout score randomly set to $layoutPoints...',
              grantedPoints: layoutPoints,
              maxPoints: 30,
            ),
            status:
                layoutPoints > 20 ? ReportStatus.passed : ReportStatus.failed,
          ),
          ReportSection(
            id: ReportSectionId.documentation,
            title: 'Fake documentation',
            grantedPoints: examplePoints,
            maxPoints: 30,
            summary: renderSimpleSectionSummary(
              title: 'Example',
              description: 'Example score randomly set to $examplePoints...',
              grantedPoints: examplePoints,
              maxPoints: 30,
            ),
            status:
                examplePoints > 20 ? ReportStatus.passed : ReportStatus.partial,
          ),
        ],
      ),
      licenseFile: LicenseFile('LICENSE', 'BSD'),
      errorMessage: null,
      pubspec: null, // will be ignored
    );
  }