diff --git a/.github/workflows/check-all-lint-rule-diffs.yaml b/.github/workflows/check-all-lint-rule-diffs.yaml index 4b200b4..fdaead9 100644 --- a/.github/workflows/check-all-lint-rule-diffs.yaml +++ b/.github/workflows/check-all-lint-rule-diffs.yaml @@ -2,8 +2,6 @@ name: Check all lint rule diffs on: workflow_dispatch: - schedule: - - cron: '0 0 15 * *' env: branch: "update-all-lint-rules" diff --git a/.github/workflows/update-all-lint-rules.yaml b/.github/workflows/update-all-lint-rules.yaml new file mode 100644 index 0000000..a299d6a --- /dev/null +++ b/.github/workflows/update-all-lint-rules.yaml @@ -0,0 +1,73 @@ +name: Update all lint rules + +on: + schedule: + - cron: '0 0 * * 3' + workflow_dispatch: + +env: + branch: "update-all-lint-rules" + +jobs: + update: + runs-on: ubuntu-latest + timeout-minutes: 10 + outputs: + has_diff: ${{ steps.output.outputs.has_diff }} + steps: + - uses: actions/checkout@v4 + - uses: dart-lang/setup-dart@v1 + - name: run + working-directory: ./packages/diffscrape + run: dart run diffscrape + - name: output diff + id: output + run: echo "diff_count=$(git diff --name-only --relative=packages/altive_lints/lib | wc -l)" >> "$GITHUB_ENV" + - name: Create branch + if: env.diff_count != '0' + run: | + git switch -c ${{ env.branch }} + git push origin ${{ env.branch }} + - name: Git config + if: env.diff_count != '0' + run: | + git remote set-url origin https://github-actions:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY} + git config --global user.name "${GITHUB_ACTOR}" + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + - name: Commit & Push + if: env.diff_count != '0' + run: | + git add . + git commit -m "feat: update all_lint_rules" + git push origin ${{ env.branch }} + - name: Output flag + run: echo "has_diff=${{ env.diff_count != '0' }}" >> "$GITHUB_OUTPUT" + + pull-request: + name: Create Pull-Request + runs-on: ubuntu-latest + needs: [update] + if: ${{ needs.diff.outputs.has_diff == 'true' }} + steps: + - uses: actions/checkout@v4 + - name: Generate GiHub App token + id: generate_token + uses: actions/create-github-app-token@v1 + with: + app_id: ${{ secrets.PR_WRITER_APP_ID }} + private_key: ${{ secrets.PR_WRITER_PRIVATE_KEY }} + + - name: Create PR + env: + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + run: gh pr create -B $GITHUB_REF -t ${{ env.branch }} -b "" -a $GITHUB_ACTOR -H ${{ env.branch }} + + - name: Revoke GitHub Apps token + env: + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + curl --location --silent --request DELETE \ + --url "${GITHUB_API_URL}/installation/token" \ + --header "Accept: application/vnd.github+json" \ + --header "X-GitHub-Api-Version: 2022-11-28" \ + --header "Authorization: Bearer ${GITHUB_TOKEN}" diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..6ee3768 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "diffscrape", + "cwd": "packages/diffscrape", + "request": "launch", + "type": "dart", + "args": [ + "diffscrape", + "--uri", + "https://dart.dev/tools/linter-rules/all", + "--file", + "../altive_lints/lib/all_lint_rules.yaml", + "--query-selector", + "pre code.yaml", + "--verbose" + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 294a0cc..d0da4fe 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,7 +8,16 @@ "gocolly", "interps", "ints", + "pubspec", + "redeclares", "tearoffs", - "todos" - ] + "todos", + "unawaited", + "writeln" + ], + "yaml.schemas": { + "https://json.schemastore.org/yamllint.json": [ + "*.yaml", + ] + } } \ No newline at end of file diff --git a/packages/diffscrape/.gitignore b/packages/diffscrape/.gitignore new file mode 100644 index 0000000..3a85790 --- /dev/null +++ b/packages/diffscrape/.gitignore @@ -0,0 +1,3 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ diff --git a/packages/diffscrape/CHANGELOG.md b/packages/diffscrape/CHANGELOG.md new file mode 100644 index 0000000..b78d64c --- /dev/null +++ b/packages/diffscrape/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +- Initial version. diff --git a/packages/diffscrape/README.md b/packages/diffscrape/README.md new file mode 100644 index 0000000..8bdd5ec --- /dev/null +++ b/packages/diffscrape/README.md @@ -0,0 +1,26 @@ +# Diffscrape + +## What is it? + +Diffscrape is a tool for scraping web and file diffs. + +## Interface + +### uri +URL of the scraping destination. + +### file +Files to be compared. Any differences will be overwritten. + +### query-selector +Selector for searching elements in HTML. + +A sample command-line application providing basic argument parsing with an entrypoint in `bin/`. + +```shell +dart run diffscrape \ +--uri "https://dart.dev/tools/linter-rules/all" \ +--file "../altive_lints/lib/all_lint_rules.yaml" \ +--query-selector "pre code.yaml" \ +--verbose +``` diff --git a/packages/diffscrape/analysis_options.yaml b/packages/diffscrape/analysis_options.yaml new file mode 100644 index 0000000..1e27888 --- /dev/null +++ b/packages/diffscrape/analysis_options.yaml @@ -0,0 +1,5 @@ +include: package:altive_lints/altive_lints.yaml + +linter: + rules: + - avoid_print: false diff --git a/packages/diffscrape/bin/diffscrape.dart b/packages/diffscrape/bin/diffscrape.dart new file mode 100644 index 0000000..219610e --- /dev/null +++ b/packages/diffscrape/bin/diffscrape.dart @@ -0,0 +1,42 @@ +import 'package:args/args.dart'; +import 'package:diffscrape/diffscrape.dart'; +import 'package:diffscrape/src/arg.dart'; +import 'package:diffscrape/src/util.dart'; + +const String version = '0.0.1'; + +void main(List arguments) { + final argParser = buildParser(); + final ArgResults results; + try { + results = argParser.parse(arguments); + } on FormatException catch (e) { + // Print usage information if an invalid argument was provided. + print(e.message); + print(''); + printUsage(argParser); + return; + } + + if (results.wasParsed('help')) { + printUsage(argParser); + return; + } + if (results.wasParsed('version')) { + print('diffscrape version: $version'); + return; + } + + final verbose = results.wasParsed('verbose'); + + print('Positional arguments: ${results.rest}'); + if (verbose) { + print('[VERBOSE] All arguments: ${results.arguments}'); + } + scrape( + uriPath: results[argUri] as String, + filePath: results[argFile] as String, + querySelector: results[argQuerySelector] as String, + verbose: verbose, + ); +} diff --git a/packages/diffscrape/lib/diffscrape.dart b/packages/diffscrape/lib/diffscrape.dart new file mode 100644 index 0000000..a52cb4c --- /dev/null +++ b/packages/diffscrape/lib/diffscrape.dart @@ -0,0 +1,103 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:html/parser.dart'; +import 'package:http/http.dart' as http; + +typedef Diff = Set; +typedef Diffs = ({Diff inserts, Diff deletes}); +const noDiff = (inserts: {}, deletes: {}); + +/// [uriPath] のURLをスクレイピングして [filePath] のファイルと差分あれば、 +/// そのファイルをスクレイピングした内容で上書きする。 +/// +/// [uriPath] は、スクレイピング先のURLパス。 +/// [filePath] は、スクレイピング結果と比較し上書きしたいファイルのパス。 +/// [querySelector] は、スクレイピング先のHTMLのクエリセレクタ。 +/// [verbose] は、詳細な出力をするかどうか。 +Future scrape({ + required String uriPath, + required String filePath, + required String querySelector, + required bool verbose, +}) async { + final uri = Uri.tryParse(uriPath); + if (uri == null) { + stderr.writeln('Invalid URI: $uriPath'); + exit(1); + } + if (!await FileSystemEntity.isFile(filePath)) { + stderr.writeln('Invalid file path: $filePath'); + exit(1); + } + final file = File(filePath); + + final oldSets = await _readFile(file, verbose); + + final newRulesText = await _scrape( + uri: uri, + querySelector: querySelector, + verbose: verbose, + ); + final newSets = newRulesText.split('\n').toSet(); + + if (oldSets == newSets) { + print('No diff.'); + return noDiff; + } + + final inserts = oldSets.difference(newSets); + print('inserts length: ${inserts.length}'); + if (verbose && inserts.isNotEmpty) { + print('[VERBOSE] inserts: $inserts'); + } + final deletes = newSets.difference(oldSets); + print('deletes length: ${deletes.length}'); + if (verbose && deletes.isNotEmpty) { + print('[VERBOSE] deletes: $deletes'); + } + + await _writeToFile(file, newRulesText); + + return (inserts: inserts, deletes: deletes); +} + +Future _readFile(File file, bool verbose) async { + final lines = utf8.decoder.bind(file.openRead()).transform(LineSplitter()); + final set = {}; + await for (final line in lines) { + set.add(line); + } + if (verbose) { + print('[VERBOSE] oldValue: $set'); + } + return set; +} + +Future _scrape({ + required Uri uri, + required String querySelector, + required bool verbose, +}) async { + // scraping HTML. + final response = await http.get(uri); + if (response.statusCode != 200) { + stderr.writeln('Failed to get HTML: ${response.statusCode}'); + exit(1); + } + final document = parse(response.body); + + final element = document.querySelectorAll(querySelector).firstOrNull?.text; + if (element == null) { + stderr.writeln('No elements found.'); + exit(1); + } + if (verbose) { + print('[VERBOSE] scraped element: $element'); + } + return element; +} + +Future _writeToFile(File file, String value) async { + await file.writeAsString('$value\n', mode: FileMode.writeOnly); +} diff --git a/packages/diffscrape/lib/src/arg.dart b/packages/diffscrape/lib/src/arg.dart new file mode 100644 index 0000000..e35573e --- /dev/null +++ b/packages/diffscrape/lib/src/arg.dart @@ -0,0 +1,51 @@ +import 'package:args/args.dart'; + +const argUri = 'uri'; +const argFile = 'file'; +const argQuerySelector = 'query-selector'; +const argFilteringPrefix = 'filtering-prefix'; + +ArgParser buildParser() { + return ArgParser() + ..addOption( + argUri, + abbr: 'u', + mandatory: true, + help: 'URI to scrape.', + ) + ..addOption( + argFile, + abbr: 'f', + mandatory: true, + help: 'Path to the file to compare against.', + ) + ..addOption( + argQuerySelector, + abbr: 'q', + mandatory: true, + help: 'HTML query selector for the result.', + ) + ..addOption( + argFilteringPrefix, + abbr: 'p', + help: 'Filtering prefix for the result.', + ) + // common flags. + ..addFlag( + 'help', + abbr: 'h', + negatable: false, + help: 'Print this usage information.', + ) + ..addFlag( + 'verbose', + abbr: 'v', + negatable: false, + help: 'Show additional command output.', + ) + ..addFlag( + 'version', + negatable: false, + help: 'Print the tool version.', + ); +} diff --git a/packages/diffscrape/lib/src/util.dart b/packages/diffscrape/lib/src/util.dart new file mode 100644 index 0000000..e59caf5 --- /dev/null +++ b/packages/diffscrape/lib/src/util.dart @@ -0,0 +1,6 @@ +import 'package:args/args.dart'; + +void printUsage(ArgParser argParser) { + print('Usage: dart diffscrape.dart [arguments]'); + print(argParser.usage); +} diff --git a/packages/diffscrape/pubspec.lock b/packages/diffscrape/pubspec.lock new file mode 100644 index 0000000..b13b316 --- /dev/null +++ b/packages/diffscrape/pubspec.lock @@ -0,0 +1,405 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49" + url: "https://pub.dev" + source: hosted + version: "65.0.0" + altive_lints: + dependency: "direct dev" + description: + name: altive_lints + sha256: ba89baff059dd26160d8299a35de6e9ab3455c24d963c2b8bcf927628dfc4e2a + url: "https://pub.dev" + source: hosted + version: "1.9.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07 + url: "https://pub.dev" + source: hosted + version: "6.3.0" + args: + dependency: "direct main" + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + collection: + dependency: transitive + description: + name: collection + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + coverage: + dependency: transitive + description: + name: coverage + sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76" + url: "https://pub.dev" + source: hosted + version: "1.7.2" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" + csslib: + dependency: transitive + description: + name: csslib + sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + file: + dependency: transitive + description: + name: file + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" + url: "https://pub.dev" + source: hosted + version: "3.2.0" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + html: + dependency: "direct main" + description: + name: html + sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a" + url: "https://pub.dev" + source: hosted + version: "0.15.4" + http: + dependency: "direct main" + description: + name: http + sha256: d4872660c46d929f6b8a9ef4e7a7eff7e49bbf0c4ec3f385ee32df5119175139 + url: "https://pub.dev" + source: hosted + version: "1.1.2" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" + source: hosted + version: "0.12.16+1" + meta: + dependency: transitive + description: + name: meta + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + url: "https://pub.dev" + source: hosted + version: "1.11.0" + mime: + dependency: transitive + description: + name: mime + sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + url: "https://pub.dev" + source: hosted + version: "1.0.4" + node_preamble: + dependency: transitive + description: + name: node_preamble + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + path: + dependency: transitive + description: + name: path + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" + source: hosted + version: "1.9.0" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + shelf: + dependency: transitive + description: + name: shelf + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" + source: hosted + version: "1.4.1" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + shelf_static: + dependency: transitive + description: + name: shelf_static + sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e + url: "https://pub.dev" + source: hosted + version: "1.1.2" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + source_maps: + dependency: transitive + description: + name: source_maps + sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" + url: "https://pub.dev" + source: hosted + version: "0.10.12" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" + source: hosted + version: "1.11.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" + source: hosted + version: "2.1.2" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test: + dependency: "direct dev" + description: + name: test + sha256: "3d028996109ad5c253674c7f347822fb994a087614d6f353e6039704b4661ff2" + url: "https://pub.dev" + source: hosted + version: "1.25.0" + test_api: + dependency: transitive + description: + name: test_api + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" + url: "https://pub.dev" + source: hosted + version: "0.7.0" + test_core: + dependency: transitive + description: + name: test_core + sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4" + url: "https://pub.dev" + source: hosted + version: "0.6.0" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: a2662fb1f114f4296cf3f5a50786a2d888268d7776cf681aa17d660ffa23b246 + url: "https://pub.dev" + source: hosted + version: "14.0.0" + watcher: + dependency: transitive + description: + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + web: + dependency: transitive + description: + name: web + sha256: edc8a9573dd8c5a83a183dae1af2b6fd4131377404706ca4e5420474784906fa + url: "https://pub.dev" + source: hosted + version: "0.4.0" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: "045ec2137c27bf1a32e6ffa0e734d532a6677bf9016a0d1a406c54e499ff945b" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" +sdks: + dart: ">=3.2.3 <4.0.0" diff --git a/packages/diffscrape/pubspec.yaml b/packages/diffscrape/pubspec.yaml new file mode 100644 index 0000000..00d2ecf --- /dev/null +++ b/packages/diffscrape/pubspec.yaml @@ -0,0 +1,17 @@ +name: diffscrape +description: A sample command-line application with basic argument parsing. +version: 0.0.1 +publish_to: none +repository: https://github.com/altive/altive_lints + +environment: + sdk: ^3.2.3 + +dependencies: + args: ^2.4.2 + html: ^0.15.4 + http: ^1.1.2 + +dev_dependencies: + altive_lints: ^1.9.0 + test: ^1.24.0 diff --git a/packages/diffscrape/test/data/deleted_rules.yaml b/packages/diffscrape/test/data/deleted_rules.yaml new file mode 100644 index 0000000..40187e0 --- /dev/null +++ b/packages/diffscrape/test/data/deleted_rules.yaml @@ -0,0 +1,218 @@ +linter: + rules: + - always_put_control_body_on_new_line + - always_put_required_named_parameters_first + - always_require_non_null_named_parameters + - always_specify_types + - always_use_package_imports + - annotate_overrides + - annotate_redeclares + - avoid_annotating_with_dynamic + - avoid_bool_literals_in_conditional_expressions + - avoid_catches_without_on_clauses + - avoid_catching_errors + - avoid_classes_with_only_static_members + - avoid_double_and_int_checks + - avoid_dynamic_calls + - avoid_empty_else + - avoid_equals_and_hash_code_on_mutable_classes + - avoid_escaping_inner_quotes + - avoid_field_initializers_in_const_classes + - avoid_final_parameters + - avoid_function_literals_in_foreach_calls + - avoid_implementing_value_types + - avoid_init_to_null + - avoid_js_rounded_ints + - avoid_multiple_declarations_per_line + - avoid_null_checks_in_equality_operators + - avoid_positional_boolean_parameters + - avoid_print + - avoid_private_typedef_functions + - avoid_redundant_argument_values + - avoid_relative_lib_imports + - avoid_renaming_method_parameters + - avoid_return_types_on_setters + - avoid_returning_null + - avoid_returning_null_for_future + - avoid_returning_null_for_void + - avoid_returning_this + - avoid_setters_without_getters + - avoid_shadowing_type_parameters + - avoid_single_cascade_in_expression_statements + - avoid_slow_async_io + - avoid_type_to_string + - avoid_types_on_closure_parameters + - avoid_unnecessary_containers + - avoid_unstable_final_fields + - avoid_unused_constructor_parameters + - avoid_void_async + - avoid_web_libraries_in_flutter + - await_only_futures + - camel_case_extensions + - camel_case_types + - cancel_subscriptions + - cascade_invocations + - cast_nullable_to_non_nullable + - close_sinks + - collection_methods_unrelated_type + - combinators_ordering + - comment_references + - conditional_uri_does_not_exist + - constant_identifier_names + - control_flow_in_finally + - curly_braces_in_flow_control_structures + - dangling_library_doc_comments + - depend_on_referenced_packages + - deprecated_consistency + - deprecated_member_use_from_same_package + - diagnostic_describe_all_properties + - directives_ordering + - discarded_futures + - do_not_use_environment + - empty_catches + - empty_constructor_bodies + - empty_statements + - eol_at_end_of_file + - exhaustive_cases + - file_names + - flutter_style_todos + - hash_and_equals + - implementation_imports + - implicit_call_tearoffs + - implicit_reopen + - invalid_case_patterns + - iterable_contains_unrelated_type + - join_return_with_assignment + - leading_newlines_in_multiline_strings + - library_annotations + - library_names + - library_prefixes + - library_private_types_in_public_api + - lines_longer_than_80_chars + - list_remove_unrelated_type + - literal_only_boolean_expressions + - matching_super_parameters + - missing_whitespace_between_adjacent_strings + - no_adjacent_strings_in_list + - no_default_cases + - no_duplicate_case_values + - no_leading_underscores_for_library_prefixes + - no_leading_underscores_for_local_identifiers + - no_literal_bool_comparisons + - no_logic_in_create_state + - no_self_assignments + - no_wildcard_variable_uses + - non_constant_identifier_names + - noop_primitive_operations + - null_check_on_nullable_type_parameter + - null_closures + - omit_local_variable_types + - one_member_abstracts + - only_throw_errors + - overridden_fields + - package_api_docs + - package_names + - package_prefixed_library_names + - parameter_assignments + - prefer_adjacent_string_concatenation + - prefer_asserts_in_initializer_lists + - prefer_asserts_with_message + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_const_constructors + - prefer_const_constructors_in_immutables + - prefer_const_declarations + - prefer_const_literals_to_create_immutables + - prefer_constructors_over_static_methods + - prefer_contains + - prefer_double_quotes + - prefer_expression_function_bodies + - prefer_final_fields + - prefer_final_in_for_each + - prefer_final_locals + - prefer_final_parameters + - prefer_for_elements_to_map_fromIterable + - prefer_foreach + - prefer_function_declarations_over_variables + - prefer_generic_function_type_aliases + - prefer_if_elements_to_conditional_expressions + - prefer_if_null_operators + - prefer_initializing_formals + - prefer_inlined_adds + - prefer_int_literals + - prefer_interpolation_to_compose_strings + - prefer_is_empty + - prefer_is_not_empty + - prefer_is_not_operator + - prefer_iterable_whereType + - prefer_mixin + - prefer_null_aware_method_calls + - prefer_null_aware_operators + - prefer_relative_imports + - prefer_single_quotes + - prefer_spread_collections + - prefer_typing_uninitialized_variables + - prefer_void_to_null + - provide_deprecation_message + - public_member_api_docs + - recursive_getters + - require_trailing_commas + - secure_pubspec_urls + - sized_box_for_whitespace + - sized_box_shrink_expand + - slash_for_doc_comments + - sort_child_properties_last + - sort_constructors_first + - sort_pub_dependencies + - sort_unnamed_constructors_first + - test_types_in_equals + - throw_in_finally + - tighten_type_of_initializing_formals + - type_annotate_public_apis + - type_init_formals + - type_literal_in_constant_pattern + - unawaited_futures + - unnecessary_await_in_return + - unnecessary_brace_in_string_interps + - unnecessary_breaks + - unnecessary_const + - unnecessary_constructor_name + - unnecessary_final + - unnecessary_getters_setters + - unnecessary_lambdas + - unnecessary_late + - unnecessary_library_directive + - unnecessary_new + - unnecessary_null_aware_assignments + - unnecessary_null_in_if_null_operators + - unnecessary_nullable_for_final_variable_declarations + - unnecessary_overrides + - unnecessary_parenthesis + - unnecessary_raw_strings + - unnecessary_statements + - unnecessary_string_escapes + - unnecessary_string_interpolations + - unnecessary_this + - unnecessary_to_list_in_spreads + - unreachable_from_main + - unrelated_type_equality_checks + - unsafe_html + - use_build_context_synchronously + - use_colored_box + - use_decorated_box + - use_enums + - use_full_hex_values_for_flutter_colors + - use_function_type_syntax_for_parameters + - use_if_null_to_convert_nulls_to_bools + - use_is_even_rather_than_modulo + - use_key_in_widget_constructors + - use_late_for_private_fields_and_variables + - use_named_constants + - use_rethrow_when_possible + - use_setters_to_change_properties + - use_string_buffers + - use_string_in_part_of_directives + - use_super_parameters + - use_test_throws_matchers + - use_to_and_as_if_applicable + - valid_regexps diff --git a/packages/diffscrape/test/data/inserted_and_deleted_rules.yaml b/packages/diffscrape/test/data/inserted_and_deleted_rules.yaml new file mode 100644 index 0000000..3fed595 --- /dev/null +++ b/packages/diffscrape/test/data/inserted_and_deleted_rules.yaml @@ -0,0 +1,224 @@ +linter: + rules: + - aa_dummy_rule + - always_put_control_body_on_new_line + - always_put_required_named_parameters_first + - always_require_non_null_named_parameters + - always_specify_types + - always_use_package_imports + - annotate_overrides + - annotate_redeclares + - avoid_annotating_with_dynamic + - avoid_bool_literals_in_conditional_expressions + - avoid_catches_without_on_clauses + - avoid_catching_errors + - avoid_double_and_int_checks + - avoid_dynamic_calls + - avoid_empty_else + - avoid_equals_and_hash_code_on_mutable_classes + - avoid_escaping_inner_quotes + - avoid_field_initializers_in_const_classes + - avoid_final_parameters + - avoid_function_literals_in_foreach_calls + - avoid_implementing_value_types + - avoid_init_to_null + - avoid_js_rounded_ints + - avoid_multiple_declarations_per_line + - avoid_null_checks_in_equality_operators + - avoid_positional_boolean_parameters + - avoid_print + - avoid_private_typedef_functions + - avoid_redundant_argument_values + - avoid_relative_lib_imports + - avoid_renaming_method_parameters + - avoid_returning_null + - avoid_returning_null_for_future + - avoid_returning_null_for_void + - avoid_returning_this + - avoid_setters_without_getters + - avoid_shadowing_type_parameters + - avoid_single_cascade_in_expression_statements + - avoid_slow_async_io + - avoid_type_to_string + - avoid_types_as_parameter_names + - avoid_types_on_closure_parameters + - avoid_unnecessary_containers + - avoid_unstable_final_fields + - avoid_unused_constructor_parameters + - avoid_void_async + - avoid_web_libraries_in_flutter + - await_only_futures + - camel_case_extensions + - camel_case_types + - cancel_subscriptions + - cascade_invocations + - cast_nullable_to_non_nullable + - close_sinks + - collection_methods_unrelated_type + - combinators_ordering + - comment_references + - conditional_uri_does_not_exist + - constant_identifier_names + - control_flow_in_finally + - cp_dummy_rule + - cq_dummy_rule + - curly_braces_in_flow_control_structures + - dangling_library_doc_comments + - depend_on_referenced_packages + - deprecated_consistency + - deprecated_member_use_from_same_package + - diagnostic_describe_all_properties + - directives_ordering + - discarded_futures + - do_not_use_environment + - empty_catches + - empty_constructor_bodies + - empty_statements + - eol_at_end_of_file + - exhaustive_cases + - file_names + - flutter_style_todos + - hash_and_equals + - implementation_imports + - implicit_call_tearoffs + - implicit_reopen + - invalid_case_patterns + - iterable_contains_unrelated_type + - join_return_with_assignment + - leading_newlines_in_multiline_strings + - library_annotations + - library_names + - library_prefixes + - library_private_types_in_public_api + - lines_longer_than_80_chars + - list_remove_unrelated_type + - literal_only_boolean_expressions + - matching_super_parameters + - missing_whitespace_between_adjacent_strings + - no_adjacent_strings_in_list + - no_default_cases + - no_leading_underscores_for_local_identifiers + - no_literal_bool_comparisons + - no_logic_in_create_state + - no_runtimeType_toString + - no_self_assignments + - no_wildcard_variable_uses + - non_constant_identifier_names + - noop_primitive_operations + - null_check_on_nullable_type_parameter + - null_closures + - omit_local_variable_types + - one_member_abstracts + - only_throw_errors + - overridden_fields + - package_api_docs + - package_names + - package_prefixed_library_names + - parameter_assignments + - prefer_adjacent_string_concatenation + - prefer_asserts_in_initializer_lists + - prefer_asserts_with_message + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_const_constructors + - prefer_const_constructors_in_immutables + - prefer_const_declarations + - prefer_const_literals_to_create_immutables + - prefer_constructors_over_static_methods + - prefer_contains + - prefer_double_quotes + - prefer_expression_function_bodies + - prefer_final_fields + - prefer_final_in_for_each + - prefer_final_locals + - prefer_final_parameters + - prefer_for_elements_to_map_fromIterable + - prefer_foreach + - prefer_function_declarations_over_variables + - prefer_generic_function_type_aliases + - prefer_if_elements_to_conditional_expressions + - prefer_if_null_operators + - prefer_initializing_formals + - prefer_inlined_adds + - prefer_int_literals + - prefer_interpolation_to_compose_strings + - prefer_is_empty + - prefer_is_not_empty + - prefer_is_not_operator + - prefer_iterable_whereType + - prefer_mixin + - prefer_null_aware_method_calls + - prefer_null_aware_operators + - prefer_relative_imports + - prefer_single_quotes + - prefer_spread_collections + - prefer_typing_uninitialized_variables + - prefer_void_to_null + - provide_deprecation_message + - public_member_api_docs + - recursive_getters + - require_trailing_commas + - secure_pubspec_urls + - sized_box_for_whitespace + - sized_box_shrink_expand + - slash_for_doc_comments + - sort_child_properties_last + - sort_constructors_first + - sort_pub_dependencies + - sort_unnamed_constructors_first + - test_types_in_equals + - throw_in_finally + - tighten_type_of_initializing_formals + - type_annotate_public_apis + - type_init_formals + - type_literal_in_constant_pattern + - unawaited_futures + - unnecessary_await_in_return + - unnecessary_brace_in_string_interps + - unnecessary_breaks + - unnecessary_const + - unnecessary_constructor_name + - unnecessary_final + - unnecessary_getters_setters + - unnecessary_lambdas + - unnecessary_late + - unnecessary_library_directive + - unnecessary_new + - unnecessary_null_aware_assignments + - unnecessary_null_checks + - unnecessary_null_in_if_null_operators + - unnecessary_nullable_for_final_variable_declarations + - unnecessary_overrides + - unnecessary_parenthesis + - unnecessary_raw_strings + - unnecessary_statements + - unnecessary_string_escapes + - unnecessary_string_interpolations + - unnecessary_this + - unnecessary_to_list_in_spreads + - unreachable_from_main + - unrelated_type_equality_checks + - unsafe_html + - use_build_context_synchronously + - use_colored_box + - use_decorated_box + - use_enums + - use_full_hex_values_for_flutter_colors + - use_function_type_syntax_for_parameters + - use_if_null_to_convert_nulls_to_bools + - use_is_even_rather_than_modulo + - use_key_in_widget_constructors + - use_late_for_private_fields_and_variables + - use_named_constants + - use_raw_strings + - use_rethrow_when_possible + - use_string_buffers + - use_string_in_part_of_directives + - use_super_parameters + - use_test_throws_matchers + - use_to_and_as_if_applicable + - valid_regexps + - void_checks + - vw_dummy_rule + - vx_dummy_rule + - vy_dummy_rule diff --git a/packages/diffscrape/test/data/inserted_rules.yaml b/packages/diffscrape/test/data/inserted_rules.yaml new file mode 100644 index 0000000..7ecadb8 --- /dev/null +++ b/packages/diffscrape/test/data/inserted_rules.yaml @@ -0,0 +1,231 @@ +linter: + rules: + - aa_dummy_rule + - ab_dummy_rule + - always_declare_return_types + - always_put_control_body_on_new_line + - always_put_required_named_parameters_first + - always_require_non_null_named_parameters + - always_specify_types + - always_use_package_imports + - annotate_overrides + - annotate_redeclares + - avoid_annotating_with_dynamic + - avoid_bool_literals_in_conditional_expressions + - avoid_catches_without_on_clauses + - avoid_catching_errors + - avoid_classes_with_only_static_members + - avoid_double_and_int_checks + - avoid_dynamic_calls + - avoid_empty_else + - avoid_equals_and_hash_code_on_mutable_classes + - avoid_escaping_inner_quotes + - avoid_field_initializers_in_const_classes + - avoid_final_parameters + - avoid_function_literals_in_foreach_calls + - avoid_implementing_value_types + - avoid_init_to_null + - avoid_js_rounded_ints + - avoid_multiple_declarations_per_line + - avoid_null_checks_in_equality_operators + - avoid_positional_boolean_parameters + - avoid_print + - avoid_private_typedef_functions + - avoid_redundant_argument_values + - avoid_relative_lib_imports + - avoid_renaming_method_parameters + - avoid_return_types_on_setters + - avoid_returning_null + - avoid_returning_null_for_future + - avoid_returning_null_for_void + - avoid_returning_this + - avoid_setters_without_getters + - avoid_shadowing_type_parameters + - avoid_single_cascade_in_expression_statements + - avoid_slow_async_io + - avoid_type_to_string + - avoid_types_as_parameter_names + - avoid_types_on_closure_parameters + - avoid_unnecessary_containers + - avoid_unstable_final_fields + - avoid_unused_constructor_parameters + - avoid_void_async + - avoid_web_libraries_in_flutter + - await_only_futures + - camel_case_extensions + - camel_case_types + - cancel_subscriptions + - cascade_invocations + - cast_nullable_to_non_nullable + - close_sinks + - collection_methods_unrelated_type + - combinators_ordering + - comment_references + - conditional_uri_does_not_exist + - constant_identifier_names + - control_flow_in_finally + - curly_braces_in_flow_control_structures + - dangling_library_doc_comments + - depend_on_referenced_packages + - deprecated_consistency + - deprecated_member_use_from_same_package + - diagnostic_describe_all_properties + - directives_ordering + - discarded_futures + - do_not_use_environment + - empty_catches + - empty_constructor_bodies + - empty_statements + - eol_at_end_of_file + - exhaustive_cases + - file_names + - flutter_style_todos + - hash_and_equals + - implementation_imports + - implicit_call_tearoffs + - implicit_reopen + - invalid_case_patterns + - iterable_contains_unrelated_type + - join_return_with_assignment + - leading_newlines_in_multiline_strings + - library_annotations + - library_names + - library_prefixes + - library_private_types_in_public_api + - lines_longer_than_80_chars + - list_remove_unrelated_type + - literal_only_boolean_expressions + - matching_super_parameters + - missing_whitespace_between_adjacent_strings + - no_adjacent_strings_in_list + - no_default_cases + - no_duplicate_case_values + - no_leading_underscores_for_library_prefixes + - no_leading_underscores_for_local_identifiers + - no_literal_bool_comparisons + - no_logic_in_create_state + - no_runtimeType_toString + - no_self_assignments + - no_wildcard_variable_uses + - non_constant_identifier_names + - noop_primitive_operations + - null_check_on_nullable_type_parameter + - null_closures + - omit_local_variable_types + - one_member_abstracts + - only_throw_errors + - overridden_fields + - package_api_docs + - package_names + - package_prefixed_library_names + - parameter_assignments + - prefer_adjacent_string_concatenation + - prefer_asserts_in_initializer_lists + - prefer_asserts_with_message + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_const_constructors + - prefer_const_constructors_in_immutables + - prefer_const_declarations + - prefer_const_literals_to_create_immutables + - prefer_constructors_over_static_methods + - prefer_contains + - prefer_double_quotes + - prefer_expression_function_bodies + - prefer_final_fields + - prefer_final_in_for_each + - prefer_final_locals + - prefer_final_parameters + - prefer_for_elements_to_map_fromIterable + - prefer_foreach + - prefer_function_declarations_over_variables + - prefer_generic_function_type_aliases + - prefer_if_elements_to_conditional_expressions + - prefer_if_null_operators + - prefer_initializing_formals + - prefer_inlined_adds + - prefer_int_literals + - prefer_interpolation_to_compose_strings + - prefer_is_empty + - prefer_is_not_empty + - prefer_is_not_operator + - prefer_iterable_whereType + - prefer_mixin + - prefer_null_aware_method_calls + - prefer_null_aware_operators + - prefer_relative_imports + - prefer_single_quotes + - prefer_spread_collections + - prefer_typing_uninitialized_variables + - prefer_void_to_null + - provide_deprecation_message + - public_member_api_docs + - qa_dummy_rule + - qb_dummy_rule + - recursive_getters + - require_trailing_commas + - secure_pubspec_urls + - sized_box_for_whitespace + - sized_box_shrink_expand + - slash_for_doc_comments + - sort_child_properties_last + - sort_constructors_first + - sort_pub_dependencies + - sort_unnamed_constructors_first + - test_types_in_equals + - throw_in_finally + - tighten_type_of_initializing_formals + - type_annotate_public_apis + - type_init_formals + - type_literal_in_constant_pattern + - unawaited_futures + - unnecessary_await_in_return + - unnecessary_brace_in_string_interps + - unnecessary_breaks + - unnecessary_const + - unnecessary_constructor_name + - unnecessary_final + - unnecessary_getters_setters + - unnecessary_lambdas + - unnecessary_late + - unnecessary_library_directive + - unnecessary_new + - unnecessary_null_aware_assignments + - unnecessary_null_aware_operator_on_extension_on_nullable + - unnecessary_null_checks + - unnecessary_null_in_if_null_operators + - unnecessary_nullable_for_final_variable_declarations + - unnecessary_overrides + - unnecessary_parenthesis + - unnecessary_raw_strings + - unnecessary_statements + - unnecessary_string_escapes + - unnecessary_string_interpolations + - unnecessary_this + - unnecessary_to_list_in_spreads + - unreachable_from_main + - unrelated_type_equality_checks + - unsafe_html + - use_build_context_synchronously + - use_colored_box + - use_decorated_box + - use_enums + - use_full_hex_values_for_flutter_colors + - use_function_type_syntax_for_parameters + - use_if_null_to_convert_nulls_to_bools + - use_is_even_rather_than_modulo + - use_key_in_widget_constructors + - use_late_for_private_fields_and_variables + - use_named_constants + - use_raw_strings + - use_rethrow_when_possible + - use_setters_to_change_properties + - use_string_buffers + - use_string_in_part_of_directives + - use_super_parameters + - use_test_throws_matchers + - use_to_and_as_if_applicable + - valid_regexps + - void_checks + - vx_dummy_rule + - vy_dummy_rule diff --git a/packages/diffscrape/test/data/no_changed_rules.yaml b/packages/diffscrape/test/data/no_changed_rules.yaml new file mode 100644 index 0000000..04199f1 --- /dev/null +++ b/packages/diffscrape/test/data/no_changed_rules.yaml @@ -0,0 +1,225 @@ +linter: + rules: + - always_declare_return_types + - always_put_control_body_on_new_line + - always_put_required_named_parameters_first + - always_require_non_null_named_parameters + - always_specify_types + - always_use_package_imports + - annotate_overrides + - annotate_redeclares + - avoid_annotating_with_dynamic + - avoid_bool_literals_in_conditional_expressions + - avoid_catches_without_on_clauses + - avoid_catching_errors + - avoid_classes_with_only_static_members + - avoid_double_and_int_checks + - avoid_dynamic_calls + - avoid_empty_else + - avoid_equals_and_hash_code_on_mutable_classes + - avoid_escaping_inner_quotes + - avoid_field_initializers_in_const_classes + - avoid_final_parameters + - avoid_function_literals_in_foreach_calls + - avoid_implementing_value_types + - avoid_init_to_null + - avoid_js_rounded_ints + - avoid_multiple_declarations_per_line + - avoid_null_checks_in_equality_operators + - avoid_positional_boolean_parameters + - avoid_print + - avoid_private_typedef_functions + - avoid_redundant_argument_values + - avoid_relative_lib_imports + - avoid_renaming_method_parameters + - avoid_return_types_on_setters + - avoid_returning_null + - avoid_returning_null_for_future + - avoid_returning_null_for_void + - avoid_returning_this + - avoid_setters_without_getters + - avoid_shadowing_type_parameters + - avoid_single_cascade_in_expression_statements + - avoid_slow_async_io + - avoid_type_to_string + - avoid_types_as_parameter_names + - avoid_types_on_closure_parameters + - avoid_unnecessary_containers + - avoid_unstable_final_fields + - avoid_unused_constructor_parameters + - avoid_void_async + - avoid_web_libraries_in_flutter + - await_only_futures + - camel_case_extensions + - camel_case_types + - cancel_subscriptions + - cascade_invocations + - cast_nullable_to_non_nullable + - close_sinks + - collection_methods_unrelated_type + - combinators_ordering + - comment_references + - conditional_uri_does_not_exist + - constant_identifier_names + - control_flow_in_finally + - curly_braces_in_flow_control_structures + - dangling_library_doc_comments + - depend_on_referenced_packages + - deprecated_consistency + - deprecated_member_use_from_same_package + - diagnostic_describe_all_properties + - directives_ordering + - discarded_futures + - do_not_use_environment + - empty_catches + - empty_constructor_bodies + - empty_statements + - eol_at_end_of_file + - exhaustive_cases + - file_names + - flutter_style_todos + - hash_and_equals + - implementation_imports + - implicit_call_tearoffs + - implicit_reopen + - invalid_case_patterns + - iterable_contains_unrelated_type + - join_return_with_assignment + - leading_newlines_in_multiline_strings + - library_annotations + - library_names + - library_prefixes + - library_private_types_in_public_api + - lines_longer_than_80_chars + - list_remove_unrelated_type + - literal_only_boolean_expressions + - matching_super_parameters + - missing_whitespace_between_adjacent_strings + - no_adjacent_strings_in_list + - no_default_cases + - no_duplicate_case_values + - no_leading_underscores_for_library_prefixes + - no_leading_underscores_for_local_identifiers + - no_literal_bool_comparisons + - no_logic_in_create_state + - no_runtimeType_toString + - no_self_assignments + - no_wildcard_variable_uses + - non_constant_identifier_names + - noop_primitive_operations + - null_check_on_nullable_type_parameter + - null_closures + - omit_local_variable_types + - one_member_abstracts + - only_throw_errors + - overridden_fields + - package_api_docs + - package_names + - package_prefixed_library_names + - parameter_assignments + - prefer_adjacent_string_concatenation + - prefer_asserts_in_initializer_lists + - prefer_asserts_with_message + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_const_constructors + - prefer_const_constructors_in_immutables + - prefer_const_declarations + - prefer_const_literals_to_create_immutables + - prefer_constructors_over_static_methods + - prefer_contains + - prefer_double_quotes + - prefer_expression_function_bodies + - prefer_final_fields + - prefer_final_in_for_each + - prefer_final_locals + - prefer_final_parameters + - prefer_for_elements_to_map_fromIterable + - prefer_foreach + - prefer_function_declarations_over_variables + - prefer_generic_function_type_aliases + - prefer_if_elements_to_conditional_expressions + - prefer_if_null_operators + - prefer_initializing_formals + - prefer_inlined_adds + - prefer_int_literals + - prefer_interpolation_to_compose_strings + - prefer_is_empty + - prefer_is_not_empty + - prefer_is_not_operator + - prefer_iterable_whereType + - prefer_mixin + - prefer_null_aware_method_calls + - prefer_null_aware_operators + - prefer_relative_imports + - prefer_single_quotes + - prefer_spread_collections + - prefer_typing_uninitialized_variables + - prefer_void_to_null + - provide_deprecation_message + - public_member_api_docs + - recursive_getters + - require_trailing_commas + - secure_pubspec_urls + - sized_box_for_whitespace + - sized_box_shrink_expand + - slash_for_doc_comments + - sort_child_properties_last + - sort_constructors_first + - sort_pub_dependencies + - sort_unnamed_constructors_first + - test_types_in_equals + - throw_in_finally + - tighten_type_of_initializing_formals + - type_annotate_public_apis + - type_init_formals + - type_literal_in_constant_pattern + - unawaited_futures + - unnecessary_await_in_return + - unnecessary_brace_in_string_interps + - unnecessary_breaks + - unnecessary_const + - unnecessary_constructor_name + - unnecessary_final + - unnecessary_getters_setters + - unnecessary_lambdas + - unnecessary_late + - unnecessary_library_directive + - unnecessary_new + - unnecessary_null_aware_assignments + - unnecessary_null_aware_operator_on_extension_on_nullable + - unnecessary_null_checks + - unnecessary_null_in_if_null_operators + - unnecessary_nullable_for_final_variable_declarations + - unnecessary_overrides + - unnecessary_parenthesis + - unnecessary_raw_strings + - unnecessary_statements + - unnecessary_string_escapes + - unnecessary_string_interpolations + - unnecessary_this + - unnecessary_to_list_in_spreads + - unreachable_from_main + - unrelated_type_equality_checks + - unsafe_html + - use_build_context_synchronously + - use_colored_box + - use_decorated_box + - use_enums + - use_full_hex_values_for_flutter_colors + - use_function_type_syntax_for_parameters + - use_if_null_to_convert_nulls_to_bools + - use_is_even_rather_than_modulo + - use_key_in_widget_constructors + - use_late_for_private_fields_and_variables + - use_named_constants + - use_raw_strings + - use_rethrow_when_possible + - use_setters_to_change_properties + - use_string_buffers + - use_string_in_part_of_directives + - use_super_parameters + - use_test_throws_matchers + - use_to_and_as_if_applicable + - valid_regexps + - void_checks diff --git a/packages/diffscrape/test/diffscrape_test.dart b/packages/diffscrape/test/diffscrape_test.dart new file mode 100644 index 0000000..0cc525b --- /dev/null +++ b/packages/diffscrape/test/diffscrape_test.dart @@ -0,0 +1,80 @@ +import 'dart:io'; + +import 'package:diffscrape/diffscrape.dart'; +import 'package:test/test.dart'; + +void main() { + group('scrape', () { + test('no changed rules', () async { + final file = File('./test/data/no_changed_rules.yaml'); + final oldValue = await file.readAsString(); + final diffs = await scrape( + uriPath: 'https://dart.dev/tools/linter-rules/all', + filePath: file.path, + querySelector: 'pre code.yaml', + verbose: true, + ); + + addTearDown( + () => file.writeAsString('$oldValue', mode: FileMode.writeOnly), + ); + + expect(diffs.inserts, isEmpty); + expect(diffs.deletes, isEmpty); + }); + + test('inserted and deleted rules', () async { + final file = File('./test/data/inserted_and_deleted_rules.yaml'); + final oldValue = await file.readAsString(); + final diffs = await scrape( + uriPath: 'https://dart.dev/tools/linter-rules/all', + filePath: file.path, + querySelector: 'pre code.yaml', + verbose: true, + ); + + addTearDown( + () => file.writeAsString('$oldValue', mode: FileMode.writeOnly), + ); + + expect(diffs.inserts, hasLength(6)); + expect(diffs.deletes, hasLength(7)); + }); + + test('inserted rules', () async { + final file = File('./test/data/inserted_rules.yaml'); + final oldValue = await file.readAsString(); + final diffs = await scrape( + uriPath: 'https://dart.dev/tools/linter-rules/all', + filePath: file.path, + querySelector: 'pre code.yaml', + verbose: true, + ); + + addTearDown( + () => file.writeAsString('$oldValue', mode: FileMode.writeOnly), + ); + + expect(diffs.inserts, hasLength(6)); + expect(diffs.deletes, isEmpty); + }); + + test('deleted rules', () async { + final file = File('./test/data/deleted_rules.yaml'); + final oldValue = await file.readAsString(); + final diffs = await scrape( + uriPath: 'https://dart.dev/tools/linter-rules/all', + filePath: file.path, + querySelector: 'pre code.yaml', + verbose: true, + ); + + addTearDown( + () => file.writeAsString('$oldValue', mode: FileMode.writeOnly), + ); + + expect(diffs.inserts, isEmpty); + expect(diffs.deletes, hasLength(7)); + }); + }); +}