Skip to content

Commit a38953b

Browse files
MBX-3720: Modify linter rules (#134)
1 parent 6659099 commit a38953b

File tree

24 files changed

+299
-240
lines changed

24 files changed

+299
-240
lines changed

.github/workflows/analyze_and_test.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,22 @@ jobs:
6565
- run: cd mindbox_ios && flutter pub get
6666
- run: cd mindbox_ios && flutter analyze
6767
- run: cd mindbox_ios && flutter test
68-
68+
69+
example_flutter_test:
70+
name: example running analyze
71+
runs-on: ubuntu-latest
72+
steps:
73+
- uses: actions/checkout@v3
74+
- uses: actions/setup-java@v1
75+
with:
76+
java-version: "12.x"
77+
- uses: subosito/flutter-action@v2
78+
with:
79+
channel: "stable"
80+
81+
- name: lint example
82+
run: cd example/flutter_example && flutter pub get && flutter analyze
83+
6984
plugin_flutter_test:
7085
name: plugin running analyze and tests
7186
runs-on: ubuntu-latest
@@ -77,7 +92,10 @@ jobs:
7792
- uses: subosito/flutter-action@v2
7893
with:
7994
channel: "stable"
80-
95+
96+
- name: lint example
97+
run: cd example/flutter_example && flutter pub get && flutter analyze
98+
8199
- name: Add publish_to tag in mindbox_android
82100
run: |
83101
cd mindbox_android && echo "publish_to: 'none'" | cat - pubspec.yaml > temp && mv temp pubspec.yaml
Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
# This file configures the analyzer, which statically analyzes Dart code to
2-
# check for errors, warnings, and lints.
3-
#
4-
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5-
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6-
# invoked from the command line by running `flutter analyze`.
7-
8-
# The following line activates a set of recommended lints for Flutter apps,
9-
# packages, and plugins designed to encourage good coding practices.
101
include: package:flutter_lints/flutter.yaml
112

123
linter:
13-
# The lint rules applied to this project can be customized in the
14-
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15-
# included above or to enable additional rules. A list of all available lints
16-
# and their documentation is published at https://dart.dev/lints.
17-
#
18-
# Instead of disabling a lint rule for the entire project in the
19-
# section below, it can also be suppressed for a single line of code
20-
# or a specific dart file by using the `// ignore: name_of_lint` and
21-
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22-
# producing the lint.
234
rules:
24-
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25-
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
5+
file_names: false
6+
avoid_print: false
7+
lines_longer_than_80_chars: false
8+
cancel_subscriptions: true
9+
constant_identifier_names: true
10+
directives_ordering: false
11+
empty_constructor_bodies: true
12+
flutter_style_todos: true
13+
implementation_imports: true
14+
package_names: true
15+
package_prefixed_library_names: true
16+
prefer_final_locals: true
17+
sort_child_properties_last: true
18+
sort_constructors_first: true
19+
sort_unnamed_constructors_first: true
20+
type_annotate_public_apis: false
21+
unnecessary_await_in_return: true
22+
prefer_is_not_empty: true
23+
avoid_empty_else: true
24+
avoid_returning_null_for_void: true
25+
no_duplicate_case_values: true
26+
prefer_typing_uninitialized_variables: true
27+
public_member_api_docs: false
28+
always_put_control_body_on_new_line: true
29+
curly_braces_in_flow_control_structures: true
2630

27-
# Additional information about this file can be found at
28-
# https://dart.dev/guides/language/analysis-options
31+
# See lint rules here https://dart.dev/tools/linter-rules#lints

example/flutter_example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (flutterVersionName == null) {
2727
android {
2828
namespace "cloud.mindbox.flutter_example"
2929
compileSdk flutter.compileSdkVersion
30-
ndkVersion flutter.ndkVersion
30+
ndkVersion "26.1.10909125"
3131

3232
compileOptions {
3333
sourceCompatibility JavaVersion.VERSION_1_8

example/flutter_example/android/build.gradle

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
buildscript {
2-
ext.kotlin_version = '1.8.0'
2+
ext.kotlin_version = '1.9.22'
33
repositories {
44
google()
55
mavenCentral()
66
maven {url 'https://developer.huawei.com/repo/'}
77
}
88

99
dependencies {
10-
classpath 'com.android.tools.build:gradle:7.4.2'
10+
classpath 'com.android.tools.build:gradle:8.6.0'
1111
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1212
classpath 'com.google.gms:google-services:4.4.0'
1313
classpath 'com.huawei.agconnect:agcp:1.6.0.300'
@@ -25,6 +25,16 @@ allprojects {
2525
rootProject.buildDir = '../build'
2626
subprojects {
2727
project.buildDir = "${rootProject.buildDir}/${project.name}"
28+
afterEvaluate {
29+
if (it.hasProperty('android')) {
30+
if (it.android.namespace == null) {
31+
def manifest = new XmlSlurper().parse(file(it.android.sourceSets.main.manifest.srcFile))
32+
def packageName = manifest.@package.text()
33+
println("Setting ${packageName} as android namespace")
34+
android.namespace = packageName
35+
}
36+
}
37+
}
2838
project.evaluationDependsOn(':app')
2939
}
3040

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
org.gradle.jvmargs=-Xmx4G
22
android.useAndroidX=true
33
android.enableJetifier=true
4+
apmsInstrumentationEnabled=false

example/flutter_example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip

example/flutter_example/android/settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ pluginManagement {
2020

2121
plugins {
2222
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
23-
id "com.android.application" version '7.4.2' apply false
24-
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
23+
id "com.android.application" version '8.6.0' apply false
24+
id "org.jetbrains.kotlin.android" version "1.9.22" apply false
2525
}
2626

2727
include ":app"
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
class ListItem {
2-
final String uniqueKey;
3-
final String title;
4-
final String description;
5-
final String imageUrl;
6-
final String pushLink;
72

83
ListItem({
94
required this.uniqueKey,
@@ -12,4 +7,9 @@ class ListItem {
127
required this.imageUrl,
138
required this.pushLink,
149
});
10+
final String uniqueKey;
11+
final String title;
12+
final String description;
13+
final String imageUrl;
14+
final String pushLink;
1515
}

example/flutter_example/lib/models/mindbox_remote_message.dart

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ import 'payload.dart';
44

55
//example of data by push
66
class MindboxRemoteMessage {
7-
final String uniqueKey;
8-
final String title;
9-
final String description;
10-
final String? pushLink;
11-
final String? imageUrl;
12-
final List<PushAction> pushActions;
13-
final String? payload;
147

158
MindboxRemoteMessage({
169
required this.uniqueKey,
@@ -23,8 +16,8 @@ class MindboxRemoteMessage {
2316
});
2417

2518
factory MindboxRemoteMessage.fromJson(Map<String, dynamic> json) {
26-
var pushActionsFromJson = json['pushActions'] as List;
27-
List<PushAction> pushActionsList = pushActionsFromJson.map((action) => PushAction.fromJson(action)).toList();
19+
final pushActionsFromJson = json['pushActions'] as List;
20+
final List<PushAction> pushActionsList = pushActionsFromJson.map((action) => PushAction.fromJson(action)).toList();
2821

2922
return MindboxRemoteMessage(
3023
uniqueKey: json['uniqueKey'],
@@ -36,10 +29,18 @@ class MindboxRemoteMessage {
3629
payload: json['payload'],
3730
);
3831
}
32+
final String uniqueKey;
33+
final String title;
34+
final String description;
35+
final String? pushLink;
36+
final String? imageUrl;
37+
final List<PushAction> pushActions;
38+
final String? payload;
3939

4040
Payload? getPayloadObject() {
41-
if (payload == null) return null;
42-
Map<String, dynamic> payloadMap = jsonDecode(payload!);
41+
if (payload == null)
42+
{ return null; }
43+
final Map<String, dynamic> payloadMap = jsonDecode(payload!);
4344
return Payload.fromJson(payloadMap);
4445
}
4546
}

example/flutter_example/lib/models/payload.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
"pushDate":"<Push date>"
55
}*/
66
class Payload {
7-
final String pushName;
8-
final String pushDate;
97

108
Payload({required this.pushName, required this.pushDate});
119

@@ -15,6 +13,8 @@ class Payload {
1513
pushDate: json['pushDate'],
1614
);
1715
}
16+
final String pushName;
17+
final String pushDate;
1818

1919
Map<String, dynamic> toJson() {
2020
return {

0 commit comments

Comments
 (0)