Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated methods and fields. #1296

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.22.0

- Removed deprecated APIs.

## 0.21.45

- Fix: don't report hidden constructors as undocumented API symbols.
Expand Down
36 changes: 4 additions & 32 deletions lib/src/batch/batch_compare_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'dart:convert';
import 'dart:io';

import 'package:args/command_runner.dart';
import 'package:http/http.dart' as http;
import 'package:pana/src/package_analyzer.dart';
import 'package:yaml/yaml.dart' as yaml;

Expand Down Expand Up @@ -56,18 +55,15 @@ class BatchCompareCommand extends Command {
final experimentEnv = await _initToolEnv(experimentConfig, tempDir);
final controlEnv = await _initToolEnv(controlConfig, tempDir);

final experimentalOptions = await _parseOptions(experimentConfig);
final controlOptions = await _parseOptions(controlConfig);

var unchangedCount = 0;
final increased = <String, int>{};
final decreased = <String, int>{};

for (final package in packages) {
final expSummary = await PackageAnalyzer(experimentEnv)
.inspectPackage(package, options: experimentalOptions);
final controlSummary = await PackageAnalyzer(controlEnv)
.inspectPackage(package, options: controlOptions);
final expSummary =
await PackageAnalyzer(experimentEnv).inspectPackage(package);
final controlSummary =
await PackageAnalyzer(controlEnv).inspectPackage(package);

final diff = (expSummary.report?.grantedPoints ?? 0) -
(controlSummary.report?.grantedPoints ?? 0);
Expand Down Expand Up @@ -130,28 +126,4 @@ class BatchCompareCommand extends Command {
pubCacheDir: pubCache,
);
}

Future<InspectOptions> _parseOptions(BatchConfig config) async {
String? analysisOptionsYaml;
if (config.analysisOptions != null) {
if (config.analysisOptions!.startsWith('https://')) {
final rs = await http.get(Uri.parse(config.analysisOptions!));
if (rs.statusCode != 200) {
throw ArgumentError('Unable to access `${config.analysisOptions}`.');
}
analysisOptionsYaml = rs.body;
} else {
// local file
final file = File(config.analysisOptions!);
if (file.existsSync()) {
analysisOptionsYaml = await file.readAsString();
} else {
throw ArgumentError('Unable to access `${config.analysisOptions}`.');
}
}
}
return InspectOptions(
analysisOptionsYaml: analysisOptionsYaml,
);
}
}
29 changes: 1 addition & 28 deletions lib/src/batch/batch_run_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'dart:convert';
import 'dart:io';

import 'package:args/command_runner.dart';
import 'package:http/http.dart' as http;
import 'package:pana/src/package_analyzer.dart';
import 'package:yaml/yaml.dart' as yaml;

Expand Down Expand Up @@ -48,16 +47,14 @@ class BatchRunCommand extends Command {

await withTempDir((tempDir) async {
final env = await _initToolEnv(config, tempDir);
final options = await _parseOptions(config);

final results = <String, dynamic>{};

for (final package in packages) {
dynamic result;
try {
print('analyzing $package...');
final summary = await PackageAnalyzer(env)
.inspectPackage(package, options: options);
final summary = await PackageAnalyzer(env).inspectPackage(package);
result = summary.report?.grantedPoints;
} catch (e, st) {
result = '$e\n$st';
Expand Down Expand Up @@ -109,28 +106,4 @@ class BatchRunCommand extends Command {
pubCacheDir: pubCache,
);
}

Future<InspectOptions> _parseOptions(BatchConfig config) async {
String? analysisOptionsYaml;
if (config.analysisOptions != null) {
if (config.analysisOptions!.startsWith('https://')) {
final rs = await http.get(Uri.parse(config.analysisOptions!));
if (rs.statusCode != 200) {
throw ArgumentError('Unable to access `${config.analysisOptions}`.');
}
analysisOptionsYaml = rs.body;
} else {
// local file
final file = File(config.analysisOptions!);
if (file.existsSync()) {
analysisOptionsYaml = await file.readAsString();
} else {
throw ArgumentError('Unable to access `${config.analysisOptions}`.');
}
}
}
return InspectOptions(
analysisOptionsYaml: analysisOptionsYaml,
);
}
}
28 changes: 0 additions & 28 deletions lib/src/dartdoc/dartdoc_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,6 @@ import 'package:json_annotation/json_annotation.dart';

part 'dartdoc_index.g.dart';

// TODO(https://github.com/dart-lang/pana/issues/1273): remove these and use a different pub-data.json file format.
@Deprecated('Do not use, will be removed.')
const kindNames = <int, String>{
0: 'accessor',
1: 'constant',
2: 'constructor',
3: 'class',
4: 'dynamic',
5: 'enum',
6: 'extension',
7: 'extension type',
8: 'function',
9: 'library',
10: 'method',
11: 'mixin',
12: 'Never',
13: 'package',
14: 'parameter',
15: 'prefix',
16: 'property',
17: 'SDK',
18: 'topic',
19: 'top-level constant',
20: 'top-level property',
21: 'typedef',
22: 'type parameter',
};

/// The parsed content of the `index.json` generated by dartdoc.
class DartdocIndex {
final List<DartdocIndexEntry> entries;
Expand Down
2 changes: 0 additions & 2 deletions lib/src/dartdoc/index_to_pubdata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ PubDartdocData dataFromDartdocIndex(DartdocIndex index) {
}
final apiElements = <ApiElement>[];
for (final e in entries) {
final kind = e.kind == null ? null : kindNames[e.kind!];
final showHref = e.isLibrary || e.isClass;
final parent = hrefToQualifiedNames[e.enclosedBy?.href ?? ''];
apiElements.add(ApiElement(
name: e.name!,
kind: kind,
parent: parent,
source: null,
href: showHref ? e.href : null,
Expand Down
3 changes: 0 additions & 3 deletions lib/src/dartdoc/pub_dartdoc_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@ class PubDartdocData {
class ApiElement {
/// The last part of the [qualifiedName].
final String name;
@Deprecated('Do not use, will be removed.')
final String? kind;
final String? parent;
final String? source;
final String? href;
String? documentation;

ApiElement({
required this.name,
required this.kind,
required this.parent,
required this.source,
required this.href,
Expand Down
2 changes: 0 additions & 2 deletions lib/src/dartdoc/pub_dartdoc_data.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions lib/src/download_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import 'package:tar/tar.dart';

import 'internal_model.dart' show UrlStatus;
import 'logging.dart';
import 'model.dart';
import 'version.dart';

export 'internal_model.dart' show UrlStatus;
Expand Down Expand Up @@ -80,18 +79,6 @@ Future<void> downloadPackage(
}
}

/// Returns an URL that is likely the downloadable URL of the given path.
@Deprecated('The method will be removed in a future release.')
String? getRepositoryUrl(
String? repository,
String relativePath, {
String? branch,
}) {
if (repository == null) return null;
final url = Repository.tryParseUrl(repository);
return url?.resolveUrl(relativePath, branch: branch);
}

/// Checks if an URL is valid and accessible.
class UrlChecker {
/// Returns `true` if the [uri] exists,
Expand Down
18 changes: 3 additions & 15 deletions lib/src/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,14 @@ class LicenseFile {
final String path;
final String name;
final String? version;
@Deprecated('`url` is deprecated and will be removed in a future release')
final String? url;

LicenseFile(this.path, this.name, {this.version, this.url});
LicenseFile(this.path, this.name, {this.version});

factory LicenseFile.fromJson(Map<String, dynamic> json) =>
_$LicenseFileFromJson(json);

Map<String, dynamic> toJson() => _$LicenseFileToJson(this);

@Deprecated('`url` is deprecated and will be removed in a future release')
LicenseFile change({String? url}) =>
LicenseFile(path, name, version: version, url: url ?? this.url);

String get shortFormatted => version == null ? name : '$name $version';

@override
Expand All @@ -208,14 +202,10 @@ class LicenseFile {
runtimeType == other.runtimeType &&
path == other.path &&
name == other.name &&
version == other.version &&
// ignore: deprecated_member_use_from_same_package
url == other.url;
version == other.version;

@override
int get hashCode =>
// ignore: deprecated_member_use_from_same_package
path.hashCode ^ name.hashCode ^ version.hashCode ^ url.hashCode;
int get hashCode => path.hashCode ^ name.hashCode ^ version.hashCode;
}

abstract class LicenseNames {
Expand Down Expand Up @@ -291,8 +281,6 @@ abstract class ReportSectionId {
static const dependency = 'dependency';
static const documentation = 'documentation';
static const platform = 'platform';
@Deprecated('No longer in use')
static const nullSafety = 'null-safety';
}

enum ReportStatus {
Expand Down
2 changes: 0 additions & 2 deletions lib/src/model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions lib/src/package_analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,17 @@ import 'utils.dart';
class InspectOptions {
final String? pubHostedUrl;
final String? dartdocOutputDir;
@Deprecated('Do not use, will be removed.')
final int dartdocRetry;
final Duration? dartdocTimeout;
@Deprecated('Do not use, will be removed.')
final bool isInternal;
final int? lineLength;

/// The analysis options (in yaml format) to use for the analysis.
@Deprecated('Do not use, will be removed.')
final String? analysisOptionsYaml;

/// Whether pana should also access the remote repository specified in pubspec.yaml.
final bool checkRemoteRepository;

InspectOptions({
this.pubHostedUrl,
this.dartdocOutputDir,
@Deprecated('Do not use, will be removed.') this.dartdocRetry = 0,
this.dartdocTimeout,
@Deprecated('Do not use, will be removed.') this.isInternal = false,
this.lineLength,
this.analysisOptionsYaml,
this.checkRemoteRepository = false,
});
}
Expand Down
9 changes: 4 additions & 5 deletions lib/src/sdk_env.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,10 @@ class ToolEnvironment {
if (await analysisOptionsFile.exists()) {
originalOptions = await analysisOptionsFile.readAsString();
}
final rawOptionsContent = inspectOptions.analysisOptionsYaml ??
await getDefaultAnalysisOptionsYaml(
usesFlutter: usesFlutter,
flutterSdkDir: flutterSdkDir,
);
final rawOptionsContent = await getDefaultAnalysisOptionsYaml(
usesFlutter: usesFlutter,
flutterSdkDir: flutterSdkDir,
);
final customOptionsContent = updatePassthroughOptions(
original: originalOptions, custom: rawOptionsContent);
try {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pana
description: PAckage aNAlyzer - produce a report summarizing the health and quality of a Dart package.
version: 0.21.45
version: 0.22.0-dev
repository: https://github.com/dart-lang/pana
topics:
- tool
Expand Down
12 changes: 12 additions & 0 deletions test/download_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,21 @@
// ignore_for_file: deprecated_member_use_from_same_package

import 'package:pana/src/download_utils.dart';
import 'package:pana/src/model.dart';
import 'package:test/test.dart';

void main() {
/// Returns an URL that is likely the downloadable URL of the given path.
String? getRepositoryUrl(
String? repository,
String relativePath, {
String? branch,
}) {
if (repository == null) return null;
final url = Repository.tryParseUrl(repository);
return url?.resolveUrl(relativePath, branch: branch);
}

void testGitHubUrls(String prefix) {
test('user root', () {
expect(getRepositoryUrl('$prefix/dart-lang', 'README.md'), null);
Expand Down
Loading