diff --git a/.github/workflows/http_exception.yml b/.github/workflows/http_exception.yml new file mode 100644 index 0000000..4eb26e0 --- /dev/null +++ b/.github/workflows/http_exception.yml @@ -0,0 +1,59 @@ +name: "build" + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + workflow_dispatch: + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] # or: macos-latest, windows-latest + channel: ['2.15.0', stable, beta, dev, main] # or: 'beta', 'dev' or 'main' + + steps: + - uses: actions/checkout@v4 + + - uses: dart-lang/setup-dart@v1.6.1 + with: + sdk: ${{ matrix.channel }} + + - id: disabled_analytics_dart + name: Disabled Analytics Dart + run: dart --disable-analytics + + - name: Install dependencies + run: dart pub get + + # Verifies if the dart code is formatted well + - name: Verify formatting + run: dart format --output=none --set-exit-if-changed . + # --set-exit-if-changed stops execution if the any code is not well formatted + # --output=none prints files which needs to be formatted + + # Checks for Symantic errors. Can be configured using analysis_options.yaml + - name: Analyze project source + run: dart analyze --fatal-infos + # optionally use --fatal-warnings to stop execution if any warnings are found + + - name: Run Tests + run: | + dart pub global activate coverage + dart pub global run coverage:test_with_coverage + + # - name: Check Code Coverage + # uses: VeryGoodOpenSource/very_good_coverage@v2 + # with: + # path: "./coverage/lcov.info" + # min_coverage: 100 + + - name: Coveralls GitHub Action + uses: coverallsapp/github-action@v2.2.3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: coverage/lcov.info \ No newline at end of file diff --git a/.gitignore b/.gitignore index a340ca4..cdece35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,36 @@ +# See https://www.dartlang.org/guides/libraries/private-files +# Files and directories created by pub build/ -.idea/ packages .packages .dart_tool/ +.pub/ + +# Remove the following pattern if you wish to check in your lock file +pubspec.lock + +# Directory created by dartdoc +doc/api/ + +# JetBrains IDEs +.idea/ +/.codecov-token + +# Coverage reports +coverage/ +lcov.info + +# dotenv environment variables file +.env* + +# Avoid committing generated Javascript files: +*.dart.js +*.info.json # Produced by the --dump-info flag. +*.js # When generated by dart2js. Don't specify *.js if your + # project includes source files written in JavaScript. +*.js_ +*.js.deps +*.js.map + +.flutter-plugins +.flutter-plugins-dependencies \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e2942a1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: dart - -dart: - - stable - - dev - -#env: -# - PUB=DOWNGRADE -# - PUB=UPGRADE - -script: tool/travis.sh - -# Speed up builds by using containerization. Disable this if you need to use -# sudo in your scripts. -sudo: false - -#branches: -# only: -# - master - -cache: - directories: - - $HOME/.pub-cache diff --git a/analysis_options.yaml b/analysis_options.yaml index 2eee9d4..7c6cdc9 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -18,8 +18,8 @@ linter: - empty_statements - hash_and_equals - invariant_booleans - - iterable_contains_unrelated_type - - list_remove_unrelated_type + # - iterable_contains_unrelated_type + # - list_remove_unrelated_type - literal_only_boolean_expressions - no_adjacent_strings_in_list - no_duplicate_case_values @@ -34,7 +34,7 @@ linter: - always_declare_return_types # - always_put_control_body_on_new_line # works against dartfmt - always_put_required_named_parameters_first - - always_require_non_null_named_parameters + # - always_require_non_null_named_parameters # - always_specify_types - annotate_overrides - avoid_annotating_with_dynamic @@ -53,7 +53,7 @@ linter: # - avoid_private_typedef_functions # not considered a useful rule - avoid_renaming_method_parameters - avoid_return_types_on_setters - - avoid_returning_null + # - avoid_returning_null - avoid_returning_this - avoid_setters_without_getters - avoid_single_cascade_in_expression_statements diff --git a/lib/http_exception.dart b/lib/http_exception.dart index 0f8fd31..5f1144b 100644 --- a/lib/http_exception.dart +++ b/lib/http_exception.dart @@ -8,7 +8,7 @@ import 'http_status.dart'; class HttpException implements Exception { final int status; final String message; - final Map data; + final Map? data; const HttpException( [this.status = HttpStatus.INTERNAL_SERVER_ERROR, @@ -26,14 +26,14 @@ class HttpException implements Exception { /// 400 Bad Request class BadRequestException extends HttpException { - const BadRequestException([Map data, String detail = '']) + const BadRequestException([Map? data, String detail = '']) : super(HttpStatus.BAD_REQUEST, 'Bad Request${detail != '' ? ': ' : ''}$detail', data); } /// 401 Unauthorized class UnauthorizedException extends HttpException { - const UnauthorizedException([Map data, String detail = '']) + const UnauthorizedException([Map? data, String detail = '']) : super(HttpStatus.UNAUTHORIZED, 'Unauthorized${detail != '' ? ': ' : ''}$detail', data); } @@ -41,56 +41,56 @@ class UnauthorizedException extends HttpException { /// 402 Payment Required class PaymentRequiredException extends HttpException { const PaymentRequiredException( - [Map data, String detail = '']) + [Map? data, String detail = '']) : super(HttpStatus.PAYMENT_REQUIRED, 'Payment Required${detail != '' ? ': ' : ''}$detail', data); } /// 403 Forbidden class ForbiddenException extends HttpException { - const ForbiddenException([Map data, String detail = '']) + const ForbiddenException([Map? data, String detail = '']) : super(HttpStatus.FORBIDDEN, 'Forbidden${detail != '' ? ': ' : ''}$detail', data); } /// 404 Not Found class NotFoundException extends HttpException { - const NotFoundException([Map data, String detail = '']) + const NotFoundException([Map? data, String detail = '']) : super(HttpStatus.NOT_FOUND, 'Not Found${detail != '' ? ': ' : ''}$detail', data); } /// 405 Method Not Allowed class MethodNotAllowed extends HttpException { - const MethodNotAllowed([Map data, String detail = '']) + const MethodNotAllowed([Map? data, String detail = '']) : super(HttpStatus.METHOD_NOT_ALLOWED, 'Method Not Allowed${detail != '' ? ': ' : ''}$detail', data); } /// 406 Not Acceptable class NotAcceptableException extends HttpException { - const NotAcceptableException([Map data, String detail = '']) + const NotAcceptableException([Map? data, String detail = '']) : super(HttpStatus.NOT_ACCEPTABLE, 'Not Acceptable${detail != '' ? ': ' : ''}$detail', data); } /// 409 Conflict class ConflictException extends HttpException { - const ConflictException([Map data, String detail = '']) + const ConflictException([Map? data, String detail = '']) : super(HttpStatus.CONFLICT, 'Conflict${detail != '' ? ': ' : ''}$detail', data); } /// 410 Gone class GoneException extends HttpException { - const GoneException([Map data, String detail = '']) + const GoneException([Map? data, String detail = '']) : super(HttpStatus.GONE, 'Gone${detail != '' ? ': ' : ''}$detail', data); } /// 412 Precondition Failed class PreconditionFailedException extends HttpException { const PreconditionFailedException( - [Map data, String detail = '']) + [Map? data, String detail = '']) : super(HttpStatus.PRECONDITION_FAILED, 'Precondition Failed${detail != '' ? ': ' : ''}$detail', data); } @@ -98,7 +98,7 @@ class PreconditionFailedException extends HttpException { /// 415 Unsupported Media Type class UnsupportedMediaTypeException extends HttpException { const UnsupportedMediaTypeException( - [Map data, String detail = '']) + [Map? data, String detail = '']) : super(HttpStatus.UNSUPPORTED_MEDIA_TYPE, 'Unsupported Media Type${detail != '' ? ': ' : ''}$detail', data); } @@ -106,13 +106,14 @@ class UnsupportedMediaTypeException extends HttpException { /// 429 Too Many Requests class TooManyRequestsException extends HttpException { const TooManyRequestsException( - [Map data, String detail = '']) + [Map? data, String detail = '']) : super(429, 'Too Many Requests${detail != '' ? ': ' : ''}$detail', data); } /// 501 Not Implemented class NotImplementedException extends HttpException { - const NotImplementedException([Map data, String detail = '']) + const NotImplementedException( + [Map? data, String detail = '']) : super(HttpStatus.NOT_IMPLEMENTED, 'Not Implemented${detail != '' ? ': ' : ''}$detail', data); } @@ -120,7 +121,7 @@ class NotImplementedException extends HttpException { /// 503 Service Unavailable class ServiceUnavailableException extends HttpException { const ServiceUnavailableException( - [Map data, String detail = '']) + [Map? data, String detail = '']) : super(HttpStatus.SERVICE_UNAVAILABLE, 'Service Unavailable${detail != '' ? ': ' : ''}$detail', data); } diff --git a/pubspec.lock b/pubspec.lock deleted file mode 100644 index 3fd7f99..0000000 --- a/pubspec.lock +++ /dev/null @@ -1,362 +0,0 @@ -# Generated by pub -# See https://www.dartlang.org/tools/pub/glossary#lockfile -packages: - analyzer: - dependency: transitive - description: - name: analyzer - url: "https://pub.dartlang.org" - source: hosted - version: "0.33.0" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.5.0" - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.8" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.4" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.2" - cli_util: - dependency: transitive - description: - name: cli_util - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.3+2" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.14.11" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.6" - csslib: - dependency: transitive - description: - name: csslib - url: "https://pub.dartlang.org" - source: hosted - version: "0.14.6" - front_end: - dependency: transitive - description: - name: front_end - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.6" - glob: - dependency: transitive - description: - name: glob - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.7" - grinder: - dependency: "direct dev" - description: - name: grinder - url: "https://pub.dartlang.org" - source: hosted - version: "0.8.3" - html: - dependency: transitive - description: - name: html - url: "https://pub.dartlang.org" - source: hosted - version: "0.13.3+3" - http: - dependency: transitive - description: - name: http - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.0" - http_multi_server: - dependency: transitive - description: - name: http_multi_server - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.5" - http_parser: - dependency: transitive - description: - name: http_parser - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.3" - io: - dependency: transitive - description: - name: io - url: "https://pub.dartlang.org" - source: hosted - version: "0.3.3" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.1+1" - json_rpc_2: - dependency: transitive - description: - name: json_rpc_2 - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.9" - kernel: - dependency: transitive - description: - name: kernel - url: "https://pub.dartlang.org" - source: hosted - version: "0.3.6" - logging: - dependency: transitive - description: - name: logging - url: "https://pub.dartlang.org" - source: hosted - version: "0.11.3+2" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.3+1" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.6" - mime: - dependency: transitive - description: - name: mime - url: "https://pub.dartlang.org" - source: hosted - version: "0.9.6+2" - multi_server_socket: - dependency: transitive - description: - name: multi_server_socket - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.2" - node_preamble: - dependency: transitive - description: - name: node_preamble - url: "https://pub.dartlang.org" - source: hosted - version: "1.4.4" - package_config: - dependency: transitive - description: - name: package_config - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - package_resolver: - dependency: transitive - description: - name: package_resolver - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.6" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.2" - plugin: - dependency: transitive - description: - name: plugin - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.0+3" - pool: - dependency: transitive - description: - name: pool - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.6" - pub_semver: - dependency: transitive - description: - name: pub_semver - url: "https://pub.dartlang.org" - source: hosted - version: "1.4.2" - shelf: - dependency: transitive - description: - name: shelf - url: "https://pub.dartlang.org" - source: hosted - version: "0.7.3+3" - shelf_packages_handler: - dependency: transitive - description: - name: shelf_packages_handler - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.4" - shelf_static: - dependency: transitive - description: - name: shelf_static - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.8" - shelf_web_socket: - dependency: transitive - description: - name: shelf_web_socket - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.2+4" - source_map_stack_trace: - dependency: transitive - description: - name: source_map_stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.5" - source_maps: - dependency: transitive - description: - name: source_maps - url: "https://pub.dartlang.org" - source: hosted - version: "0.10.8" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.4.1" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.3" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.8" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.4" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" - test: - dependency: "direct dev" - description: - name: test - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.4" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.6" - utf: - dependency: transitive - description: - name: utf - url: "https://pub.dartlang.org" - source: hosted - version: "0.9.0+5" - vm_service_client: - dependency: transitive - description: - name: vm_service_client - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.6" - watcher: - dependency: transitive - description: - name: watcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.9.7+10" - web_socket_channel: - dependency: transitive - description: - name: web_socket_channel - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.9" - yaml: - dependency: transitive - description: - name: yaml - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.15" -sdks: - dart: ">=2.0.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index ac07668..1d83ffb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,15 +1,14 @@ name: http_exception -version: 0.2.1 +version: 0.2.2 description: A set of HTTP exceptions. homepage: https://github.com/bwu-dart/http_exception -authors: - - Günter Zöchbauer - - Thomas Profelt -environment: - sdk: '>=2.0.0 <3.0.0' +# authors: +# - Günter Zöchbauer +# - Thomas Profelt +# - Diego Perez -dependencies: +environment: + sdk: '>=2.15.0 <3.0.0' dev_dependencies: - grinder: ^0.8.3 - test: ^1.3.0 + test: ^1.17.12 diff --git a/tool/grind.dart b/tool/grind.dart deleted file mode 100644 index 18c337d..0000000 --- a/tool/grind.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'dart:io'; - -import 'package:grinder/grinder.dart'; - -void main(List args) => grind(args); - -final Set sourceDirs = [ - 'lib', - 'test', - 'tool', -].map((path) => Directory(path)).toSet(); - -@Task('Travis checks') -void travis() { - if (DartFmt.dryRun(sourceDirs)) { - throw Exception('Source code not formatted'); - } - - Analyzer.analyze(sourceDirs); - - TestRunner().test(); -} diff --git a/tool/travis.sh b/tool/travis.sh deleted file mode 100755 index 8bfc992..0000000 --- a/tool/travis.sh +++ /dev/null @@ -1 +0,0 @@ -pub run grinder travis