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

Set up lints #853

Merged
merged 16 commits into from
Jul 23, 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
63 changes: 49 additions & 14 deletions .github/workflows/location-prepare.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: location prepare

on:
push:
branches: [master, develop]
tags-ignore: ['*']
pull_request:
branches: [master, develop]

Expand All @@ -15,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
flutter-version: ['3.0.x', '3.3.x', '3.7.x', '3.10.0']
flutter-version: ['3.3.x', '3.7.x', '3.10.x']

steps:
- name: Clone repository
Expand All @@ -27,33 +24,71 @@ jobs:
flutter-version: ${{ matrix.flutter-version }}

- name: Set up Melos
run: dart pub global activate melos ^2.0.0
run: dart pub global activate melos ^3.0.0

- name: melos bootstrap
run: melos bootstrap

- name: Format and lint
- name: Check code formatting
if: success() || failure()
run: melos run format --no-select

- name: Run analyzer
if: success() || failure()
run: melos run lint:all
run: melos run analyze --no-select

- name: Run tests
if: success() || failure()
run: melos run test --no-select

prepare-android:
name: Android
runs-on: ubuntu-latest

steps:
- name: Clone repository
uses: actions/checkout@v3

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.10.x

- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
java-version: 17

- name: Generate Gradle wrapper
- name: Build example app
working-directory: packages/location/example
run: flutter build apk --debug --flavor=does-not-exist || true
run: flutter build apk --debug

- name: Build example app with Gradle
- name: Run ktlint
working-directory: packages/location/example/android
run: ./gradlew :app:assembleDebug
run: ./gradlew :location:ktlintCheck

prepare-ios:
name: iOS
runs-on: macos-latest

- name: Build example app with Flutter tool
steps:
- name: Clone repository
uses: actions/checkout@v3

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.10.x

- name: Install tools
run: brew install clang-format

- name: clang-format
working-directory: packages/location/ios
run: |
find . -iname '*.h' -o -iname '*.m' | xargs -I {} clang-format --dry-run --Werror {}

- name: Build example app
working-directory: packages/location/example
run: flutter build apk --debug
run: flutter build ios --debug --simulator
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ flutter_export_environment.sh

coverage

Podfile
Podfile.lock
Pods/
.symlinks/
Expand Down Expand Up @@ -48,5 +47,4 @@ build/
.classpath
.settings

# Downloaded by the plugin tools.
google-java-format-1.3-all-deps.jar
pubspec_overrides.yaml
101 changes: 0 additions & 101 deletions analysis_options.yaml

This file was deleted.

53 changes: 23 additions & 30 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,37 @@ packages:
- packages/**

scripts:
check:
run: |
melos run analyze
melos run format:dry-run
melos run test
melos run pub:dry-run
lint:all:
run: melos run analyze && melos run format-check
description: Run all static analysis checks.

analyze:
run: melos exec -- \
dart analyze . --fatal-infos
description: Run `dart analyze` in all packages.
run: |
melos exec -- \
flutter analyze --fatal-infos
description: Run `flutter analyze` for all packages.

format:
run: melos exec -- \
dart format .
description: Run `dart format` in all packages.
format:dry-run:
run: melos exec -- \
dart format . --set-exit-if-changed
description: Run `dart format` in all packages, but don't make any changes.

pub:dry-run:
run: melos exec -- \
dart pub publish --dry-run
description: Run `dart pub publish` in all packages in dry run mode.
packageFilters:
ignore:
- 'example'
description: Run `dart format` checks for all packages.

test:all:
run: melos run test --no-select
description: Run all tests available on stable channel
# TODO: re-add
# dartdoc:
# run: melos exec flutter pub run dartdoc
# description: Run dartdoc checks for all packages.

test:
run: |
melos exec -- \
"flutter test --no-pub --coverage"
description: Run `flutter test` for a specific package.
run: melos exec -- flutter test .
packageFilters:
dirExists:
- test
- 'test'
description: Run `flutter test` for selected packages.

coverage:
run: |
melos exec -- flutter test --coverage &&
melos exec -- genhtml coverage/lcov.info --output-directory=coverage/
packageFilters:
dirExists: test
description: Generate coverage for the selected package.
21 changes: 13 additions & 8 deletions packages/location/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Flutter Location Plugin
# location

[![pub package](https://img.shields.io/pub/v/location.svg)](https://pub.dartlang.org/packages/location) ![Cirrus CI - Task and Script Build Status](https://img.shields.io/cirrus/github/Lyokone/flutterlocation?task=test)
[![patrol on pub.dev][patrol_badge]][patrol_link]
[![code style][leancode_lint_badge]][leancode_lint_link]
[![powered by][docs_page_badge]][docs_page_link]
[![codecov](https://codecov.io/gh/Lyokone/flutterlocation/branch/master/graph/badge.svg)](https://codecov.io/gh/Lyokone/flutterlocation)

This plugin for [Flutter](https://flutter.io)
This plugin for [Flutter](https://flutter.dev)
handles getting a location on Android and iOS. It also provides callbacks when the location is changed.

<p align="center">
Expand All @@ -20,14 +22,11 @@ Add this to your package's `pubspec.yaml` file:

```yaml
dependencies:
location: ^4.2.0
location: ^5.0.0
```

### Android

With Flutter 1.12, all the dependencies are automatically added to your project.
If your project was created before Flutter 1.12, you might need to follow [this](https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects).

To use location background mode on Android, you have to use the enableBackgroundMode({bool enable}) API before accessing location in the background and adding necessary permissions. You should place the required permissions in your applications <your-app>/android/app/src/main/AndroidManifest.xml:

```xml
Expand Down Expand Up @@ -197,7 +196,6 @@ enum PermissionStatus {
// The permission to use location services has been denied forever by the user. No dialog will be displayed on permission request.
deniedForever
}

```

Note: you can convert the timestamp into a `DateTime` with: `DateTime.fromMillisecondsSinceEpoch(locationData.time.toInt())`
Expand All @@ -206,3 +204,10 @@ Note: you can convert the timestamp into a `DateTime` with: `DateTime.fromMillis

Please feel free to [give me any feedback](https://github.com/Lyokone/flutterlocation/issues)
helping support this plugin !

[location_badge]: https://img.shields.io/pub/v/location?label=location
[location_link]: https://pub.dev/packages/location
[leancode_lint_badge]: https://img.shields.io/badge/code%20style-leancode__lint-black
[leancode_lint_link]: https://pub.dev/packages/leancode_lint
[docs_page_badge]: https://img.shields.io/badge/documentation-docs.page-34C4AC.svg?style
[docs_page_link]: https://docs.page
5 changes: 5 additions & 0 deletions packages/location/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: package:leancode_lint/analysis_options_package.yaml

analyzer:
exclude:
- '**/*.mocks.dart'
Loading