Skip to content

Commit

Permalink
Fix a variety of minor typos (#1334)
Browse files Browse the repository at this point in the history
  • Loading branch information
parlough committed Feb 7, 2024
1 parent f52951f commit bd89ae1
Show file tree
Hide file tree
Showing 48 changed files with 136 additions and 128 deletions.
26 changes: 13 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@

## 0.21.29

- New report section: Dart 3 compatiblity.
- New report section: Dart 3 compatibility.

## 0.21.28

Expand Down Expand Up @@ -205,8 +205,8 @@
- Null safety tagger does not check `dart:` libraries.
- Removed internal hostname check from the report and score.
- Fixed: platform tagging with dart:mirrors.
- Deprected `AnalysisOptions.isInternal`.
- Detect `CONTRIBUTING.md` during repositority verification and expose if URL check succeeds.
- Deprecated `AnalysisOptions.isInternal`.
- Detect `CONTRIBUTING.md` during repository verification and expose if URL check succeeds.
- **BREAKING CHANGES** on rarely used external API:
- Removed `UrlProblemCodes.internal`.
- Removed `UrlChecker.addInternalHosts`.
Expand Down Expand Up @@ -262,7 +262,7 @@
- Cache the currently fetched depth in `GitLocalRepository`.
- List files and check all `pubspec.yaml` during repository verification.
- Typed `stdout` and `stderr` in `PanaProcessResult`.
- Updated SPDX linceses.
- Updated SPDX licenses.
- Emit `license:<license>` tag on all the detected licenses.
- Emit `license:osi-approved` and `license:fsf-libre`.

Expand All @@ -289,7 +289,7 @@
## 0.21.6

- `package:analyzer` dependency upgraded to `^3.1.0`.
- Fix dart analysis. Code problems are now propagatet to the pana report.
- Fix dart analysis. Code problems are now propagated to the pana report.
- Fix retry on version listing HTTP requests during `getVersionListing`.
- `RepositoryUrl` (private API) to detect repository patterns and resolve paths.

Expand Down Expand Up @@ -329,7 +329,7 @@
* New license detection.
* Use `package:lints/core.yaml` as default `analysis_options.yaml` override.
* Upgraded `package:analyzer` to `^2.1.0` and updated deprecated code use.
* Updated tool environemnt to use `[ dart | flutter ] format` instead of `dartfmt`.
* Updated tool environment to use `[ dart | flutter ] format` instead of `dartfmt`.
* Updated tool environment to use `flutter pub outdated` when package uses Flutter.

## 0.20.1
Expand Down Expand Up @@ -432,10 +432,10 @@
* More graceful behavior when the analyzer crashes.

## 0.15.3
* Ignore Flutter version constraint upper bounds
.
* Ignore Flutter version constraint upper bounds.

## 0.15.2
* If unsupported versions of dependencies are newer than 30 days or depend on a
* If unsupported versions of dependencies are newer than 30 days or depend on an
unreleased sdk the dependencies section will be marked as passing instead of
partial.

Expand Down Expand Up @@ -467,7 +467,7 @@
* **BREAKING** `ToolEnvironment.runProc` and `ToolEnvironment.runProcSync` now
take the executable as the first element of the argument list instead of as a
separate argument.
* If unsupported versions of dependencies are newer than 30 days or depend on a
* If unsupported versions of dependencies are newer than 30 days or depend on an
unreleased sdk the package will still be awarded points in the report.
* Better timeout message for dartdoc section
* Adjust `runProc` timeout/kill handler.
Expand Down Expand Up @@ -609,7 +609,7 @@
* Adds suggestions for why tags don't apply.
* Command line uses `--source=path` by default.
* Support platform tagging of old-style flutter plugin declarations.
* Give penality for old-style flutter plugin declarations.
* Give penalty for old-style flutter plugin declarations.

## 0.13.8

Expand Down Expand Up @@ -1212,13 +1212,13 @@ Updates:

## 0.2.3

* Lot's of stability improvements.
* Lots of stability improvements.

* Improvements to error handling.

## 0.2.2

* Lot's of cleanup to JSON output.
* Lots of cleanup to JSON output.

* Improved stability.

Expand Down
2 changes: 1 addition & 1 deletion bin/batch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import 'package:pana/src/batch/batch_run_command.dart';
/// analysisOptions: local-file.yaml
///
/// The `analysisOptions` parameter may be an URL if it starts with https://
/// The `analysisOptions` file must be self-containaing, `include` is not supported.
/// The `analysisOptions` file must be self-containing, `include` is not supported.
///
/// 4. Run batch compare:
///
Expand Down
4 changes: 3 additions & 1 deletion lib/src/dartdoc/dartdoc_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ class DartdocIndexEntry {

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

/// Wether the entry is a top-level library.
/// Whether the entry is a top-level library.
bool get isLibrary => href != null && href!.endsWith('-library.html');

/// Whether the entry is a class declaration.
bool get isClass => href != null && href!.endsWith('-class.html');
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/dartdoc/pub_dartdoc_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ApiElement {

String get qualifiedName => parent == null ? name : '$parent.$name';

/// Wether the entry is a top-level library.
/// Weather the entry is a top-level library.
late final isLibrary = href != null && href!.endsWith('-library.html');
late final isClass = href != null && href!.endsWith('-class.html');
}
Expand Down
6 changes: 3 additions & 3 deletions lib/src/license_detection/confidence.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class LicenseMismatchException implements Exception {
/// Computes the confidence of [knownLicense] matching with [unknownLicense] and
/// returns an instance of [LicenseMatch].
///
/// Throws [LicenseMismatchException] if an unaccepatable change was made or the calculated confidence is
/// lesser than the set threshold.
/// Throws [LicenseMismatchException] if an unacceptable change was made or
/// the calculated confidence is lesser than the set threshold.
@visibleForTesting
LicenseMatch licenseMatch(
LicenseWithNGrams unknownLicense,
Expand All @@ -32,7 +32,7 @@ LicenseMatch licenseMatch(
) {
if (unknownLicense.granularity != knownLicense.granularity) {
throw LicenseMismatchException(
"Can't comapare the licenses due to different granularity");
"Can't compare the licenses due to different granularity");
}
final diffs = getDiffs(
unknownLicense.tokens,
Expand Down
15 changes: 8 additions & 7 deletions lib/src/license_detection/license.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,17 @@ class LicenseMatch {
String get identifier => license.identifier;

/// Offset in the input license text considered to be possible starting point
/// of known license subtring.
/// of known license substring.
int get start => tokens.first.span.start.offset;

/// Offset in the input license text considered to be possible starting point
/// of known license subtring.
/// of known license substring.
int get end => tokens.last.span.end.offset;

/// Count of the tokens claimed in this match.
///
/// It is intialized to the number of tokens claimed by this match.
/// Incase of match with the same spdx-identifier we create a new
/// It is initialized to the number of tokens claimed by this match.
/// In case of match with the same spdx-identifier we create a new
/// instance with tokenClaimed assigned to the maximum of both
/// the identical matches.
///
Expand All @@ -168,7 +168,7 @@ class LicenseMatch {

/// Range of tokens in the unknown text claimed by this match.
///
/// Range is initilalized from start index of first
/// Range is initialized from start index of first
/// token claimed in the match
@visibleForTesting
final Range tokenRange;
Expand Down Expand Up @@ -228,7 +228,8 @@ Map<String, int> generateFrequencyTable(List<Token> tokens) {
/// to be in the form of [`<spdx-identifier>.txt`][1].
/// The [directories] are not searched recursively.
///
/// Throws if any of the [directories] contains a file not meeting the above criteria's.
/// Throws if any of the [directories] contains a file that
/// doesn't meet the above criteria.
///
/// [1]: https://spdx.dev/ids/
List<License> loadLicensesFromDirectories(Iterable<String> directories) {
Expand Down Expand Up @@ -285,7 +286,7 @@ List<License> licensesFromFile(String path) {
return licenses;
}

/// Regex to match the all the text starting from `END OF TERMS AND CONDTIONS`.
/// Regex to match the all the text starting from `END OF TERMS AND CONDITIONS`.
const _endOfTerms = 'END OF TERMS AND CONDITIONS';

/// Generates crc-32 checksum for the given list of tokens
Expand Down
45 changes: 24 additions & 21 deletions lib/src/license_detection/license_detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Future<Result> detectLicense(String text, double threshold) async {
result.sort(sortOnConfidence);
result = removeOverLappingMatches(result);
final unclaimedPercentage =
claculateUnclaimedTokenPercentage(result, unknownLicense.tokens.length);
calculateUnclaimedTokenPercentage(result, unknownLicense.tokens.length);
final longestUnclaimedTokenCount =
findLongestUnclaimedTokenRange(result, unknownLicense.tokens.length);
return Result(List.unmodifiable(result), unclaimedPercentage,
Expand All @@ -98,7 +98,7 @@ Future<Result> detectLicense(String text, double threshold) async {
/// In a worst case scenario where the error is evenly
/// distributed (breaking the token runs most times), if we
/// consider 100 tokens and threshold 0.8, we'll have
/// 4 continuos matching tokens and a mismatch.
/// 4 continuous matching tokens and a mismatch.
///
/// So this function returns the minimum number of tokens
/// or 1 (which is greater) to consider them as part
Expand All @@ -112,16 +112,17 @@ int computeGranularity(double threshold) {
return max(1, threshold ~/ (1 - threshold));
}

/// For [LicenseMatch] in [matches] having the same `spdx-identifier` the one with highest confidence
/// is considered and rest are discared.
/// Determines each [LicenseMatch] in [matches] that has the highest confidence
/// among all [LicenseMatch] with the same [LicenseMatch.identifier].
@visibleForTesting
List<LicenseMatch> removeDuplicates(List<LicenseMatch> matches) {
var identifierToLicense = <String, LicenseMatch>{};

for (var match in matches) {
if (identifierToLicense.containsKey(match.identifier)) {
var prevMatch = identifierToLicense[match.identifier];
// As both the licenses are same consider tha max of tokens claimed among these two.
// As both the licenses are same consider the
// max of tokens claimed among these two.
var tempMatch =
prevMatch!.confidence > match.confidence ? prevMatch : match;

Expand All @@ -140,11 +141,12 @@ List<LicenseMatch> removeDuplicates(List<LicenseMatch> matches) {
return identifierToLicense.values.toList();
}

/// Custom comparator to the sort the licenses based on decreasing order of confidence.
/// Custom comparator to the sort the licenses based on
/// decreasing order of confidence.
///
/// Incase the confidence detected is same for the matches, ratio of tokens claimed
/// in the unkown text to the number of tokens present in the known license text
/// is considered
/// In case the confidence detected is same for the matches,
/// the ratio of tokens claimed in the unknown text to the
/// number of tokens present in the known license text is considered
@visibleForTesting
int sortOnConfidence(LicenseMatch matchA, LicenseMatch matchB) {
if (matchA.confidence > matchB.confidence) {
Expand All @@ -163,19 +165,20 @@ int sortOnConfidence(LicenseMatch matchA, LicenseMatch matchB) {
return (matchATokensPercent > matchBTokensPercent) ? -1 : 1;
}

/// Fliters out licenses having overlapping ranges giving preferences to a match with higher token density.
/// Filters out licenses having overlapping ranges,
/// giving preference to a match with higher token density.
///
/// Token density is the product of number of tokens claimed in the range and
/// confidence score of the match. Incase of exact match we retain both
/// confidence score of the match. In case of an exact match we retain both
/// the matches so that the user can resolve them.
@visibleForTesting
List<LicenseMatch> removeOverLappingMatches(List<LicenseMatch> matches) {
var retain = List.filled(matches.length, false);
var retainedmatches = <LicenseMatch>[];
var retainedMatches = <LicenseMatch>[];

// We consider token density to retain matches of larger licenses
// having lesser confidence when compared to a smaller license
// haing a perfect match.
// having a perfect match.
for (var i = 0; i < matches.length; i++) {
var keep = true;
final matchA = matches[i];
Expand All @@ -188,15 +191,15 @@ List<LicenseMatch> removeOverLappingMatches(List<LicenseMatch> matches) {
}
final matchB = matches[j];
final rangeB = Range(matchB.tokenRange.start, matchB.tokenRange.end);
// Check if matchA is larger license containing an insatnce of
// Check if matchA is larger license containing an instance of
// smaller license within it and decide to whether retain it
// or not by comapring their token densities. Example NPL
// or not by comparing their token densities. Example NPL
// contains MPL.
if (rangeA.contains(rangeB) && retain[j]) {
final aConf = matchA.tokensClaimed * matchA.confidence;
final bConf = matchB.tokensClaimed * matchB.confidence;

// Retain both the licenses incase of a exact match,
// Retain both the licenses in case of an exact match,
// so that it can be resolved by the user.
if (aConf > bConf) {
proposals[j] = true;
Expand All @@ -218,24 +221,24 @@ List<LicenseMatch> removeOverLappingMatches(List<LicenseMatch> matches) {

for (var i = 0; i < matches.length; i++) {
if (retain[i]) {
retainedmatches.add(matches[i]);
retainedMatches.add(matches[i]);
}
}

return retainedmatches;
return retainedMatches;
}

/// Returns the ratio of tokens claimed in all the matches to the number of
/// tokens present in the unknown license.
///
/// Minimum possible score is 0 incase none of the known licenses are detected.
/// Minimum possible score is 0 in case none of the known licenses are detected.
/// The maximum score can be greater than 1 in cases where the same range of
/// tokens is claimed for two licenses.
///
/// For example NPL contains MPL in this case we detect 2 licenses in the
/// same range and hence we have a possibilty of getting a score
/// same range and hence we have a possibility of getting a score
/// than 1.
double claculateUnclaimedTokenPercentage(
double calculateUnclaimedTokenPercentage(
List<LicenseMatch> matches, int unknownTokensCount) {
var claimedTokenCount = 0;

Expand Down
10 changes: 5 additions & 5 deletions lib/src/markdown_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import 'package:source_span/source_span.dart';
import 'utils.dart';

/// The extracted content of a markdown file.
class ExctractedMarkdownContent {
class ExtractedMarkdownContent {
final List<Link> images;
final List<Link> links;
final bool isMalformedUtf8;
final double nonAsciiRatio;

ExctractedMarkdownContent({
ExtractedMarkdownContent({
required this.images,
required this.links,
required this.isMalformedUtf8,
Expand All @@ -35,12 +35,12 @@ class ExctractedMarkdownContent {
}

/// Scans a markdown text and extracts its content.
ExctractedMarkdownContent _scanMarkdownText(
ExtractedMarkdownContent _scanMarkdownText(
String text, Uri sourceUrl, bool isMalformedUtf8) {
final htmlText = markdownToHtml(text);
final html = html_parser.parseFragment(htmlText,
sourceUrl: sourceUrl.toString(), generateSpans: true);
return ExctractedMarkdownContent(
return ExtractedMarkdownContent(
images: _unique(html
.querySelectorAll('img')
.where((e) => e.attributes.containsKey('src'))
Expand All @@ -57,7 +57,7 @@ ExctractedMarkdownContent _scanMarkdownText(
List<T> _unique<T>(Iterable<T> l) => l.toSet().toList();

/// Scans a markdown file and extracts its content.
Future<ExctractedMarkdownContent> scanMarkdownFileContent(File file) async {
Future<ExtractedMarkdownContent> scanMarkdownFileContent(File file) async {
final bytes = await file.readAsBytes();
String text;
var isMalformedUtf8 = false;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class Report {
abstract class ReportSectionId {
static const analysis = 'analysis';
static const convention = 'convention';
static const dart3Compatiblity = 'dart3-compatibility';
static const dart3Compatibility = 'dart3-compatibility';
static const dependency = 'dependency';
static const documentation = 'documentation';
static const platform = 'platform';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/package_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class PackageContext {
}
} else {
return DartdocResult.error(
'Dependency resultion failed, unable to run `dartdoc`.');
'Dependency resolution failed, unable to run `dartdoc`.');
}
}();

Expand Down
2 changes: 1 addition & 1 deletion lib/src/report/dependencies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ Future<List<OutdatedVersionDescription>> computeOutdatedVersions(
Issue(
'The constraint `${hostedDependency.version}` on $name does not support the stable version `$versionString`, '
'but that version doesn\'t support the current Dart SDK version ${context.currentSdkVersion}.'
'\n\nWhen a supporting stable sdk is pubslished, this package will no longer be awarded points in this category.'),
'\n\nWhen a supporting stable sdk is published, this package will no longer be awarded points in this category.'),
OutdatedStatus.outdatedByPreview));
} else {
result.add(OutdatedVersionDescription(
Expand Down

0 comments on commit bd89ae1

Please sign in to comment.