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

move to flutter_lint #351

Merged
merged 3 commits into from
Nov 30, 2021
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
92 changes: 1 addition & 91 deletions flutter_cache_manager/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,91 +1 @@
include: package:pedantic/analysis_options.1.8.0.yaml

analyzer:
strong-mode:
implicit-casts: false
# implicit-dynamic: false
errors:
unused_import: warning
unused_local_variable: warning
dead_code: warning
invalid_override_of_non_virtual_member: error

linter:
rules:
- always_declare_return_types
- annotate_overrides
- avoid_empty_else
- avoid_function_literals_in_foreach_calls
- avoid_init_to_null
- avoid_void_async
- await_only_futures
# - avoid_implementing_value_types
- avoid_null_checks_in_equality_operators
- avoid_renaming_method_parameters
- avoid_return_types_on_setters
- avoid_returning_null
- avoid_returning_null_for_void
- avoid_types_as_parameter_names
- avoid_relative_lib_imports
- avoid_unused_constructor_parameters
- camel_case_types
- cancel_subscriptions
#- cascade_invocations
#- comment_references
#- constant_identifier_names
- control_flow_in_finally
- directives_ordering
- empty_catches
- empty_constructor_bodies
- empty_statements
- hash_and_equals
#- implementation_imports
- invariant_booleans
- iterable_contains_unrelated_type
- library_names
- library_prefixes
- list_remove_unrelated_type
- no_adjacent_strings_in_list
- no_duplicate_case_values
- non_constant_identifier_names
- omit_local_variable_types
#- only_throw_errors
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_adjacent_string_concatenation
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_const_constructors
- prefer_contains
- prefer_equal_for_default_values
- prefer_final_fields
- prefer_initializing_formals
#- prefer_int_literals
#- prefer_interpolation_to_compose_strings
- prefer_is_empty
- prefer_is_not_empty
- prefer_single_quotes
- prefer_typing_uninitialized_variables
- recursive_getters
- slash_for_doc_comments
- sort_pub_dependencies
- test_types_in_equals
- throw_in_finally
- type_init_formals
- unawaited_futures
- unnecessary_await_in_return
- unnecessary_brace_in_string_interps
- unnecessary_getters_setters
- unnecessary_lambdas
- unnecessary_null_aware_assignments
- unnecessary_statements
- unnecessary_this
- unrelated_type_equality_checks
- use_rethrow_when_possible
- valid_regexps
# Additional Dart 2.3 lints
- prefer_spread_collections
- prefer_if_elements_to_conditional_expressions
- prefer_for_elements_to_map_fromIterable
include: package:flutter_lints/flutter.yaml
30 changes: 1 addition & 29 deletions flutter_cache_manager/example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
include: package:flutter_lints/flutter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
</dict>
</plist>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Generated file. Do not edit.
//

// clang-format off

#include "generated_plugin_registrant.h"

#include <url_launcher_linux/url_launcher_plugin.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Generated file. Do not edit.
//

// clang-format off

#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_

Expand Down
1 change: 0 additions & 1 deletion flutter_cache_manager/lib/src/cache_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:flutter_cache_manager/src/result/file_info.dart';
import 'package:flutter_cache_manager/src/result/file_response.dart';
import 'package:flutter_cache_manager/src/storage/cache_object.dart';
import 'package:flutter_cache_manager/src/web/web_helper.dart';
import 'package:pedantic/pedantic.dart';
import 'package:uuid/uuid.dart';

import 'config/config.dart';
Expand Down
5 changes: 2 additions & 3 deletions flutter_cache_manager/lib/src/cache_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:async';

import 'package:flutter_cache_manager/src/config/config.dart';
import 'package:flutter_cache_manager/src/storage/file_system/file_system.dart';
import 'package:pedantic/pedantic.dart';

import '../flutter_cache_manager.dart';
import 'logger.dart';
Expand Down Expand Up @@ -86,7 +85,7 @@ class CacheStore {
_memCache[key] = cacheObject;
}
completer.complete(cacheObject);
unawaited(_futureCache.remove(key));
_futureCache.remove(key);
}));
_futureCache[key] = completer.future;
}
Expand Down Expand Up @@ -183,7 +182,7 @@ class CacheStore {
_memCache.remove(cacheObject.key);
}
if (_futureCache.containsKey(cacheObject.key)) {
unawaited(_futureCache.remove(cacheObject.key));
_futureCache.remove(cacheObject.key);
}
final file = await fileSystem.createFile(cacheObject.relativePath);
if (await file.exists()) {
Expand Down
2 changes: 1 addition & 1 deletion flutter_cache_manager/lib/src/compat/file_fetcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:http/http.dart' as http;
///Released under MIT License.

/// Deprecated FileFetcher function
typedef Future<FileFetcherResponse> FileFetcher(String url,
typedef FileFetcher = Future<FileFetcherResponse> Function(String url,
{Map<String, String>? headers});

abstract class FileFetcherResponse {
Expand Down
1 change: 1 addition & 0 deletions flutter_cache_manager/lib/src/logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class CacheLogger {
/// Function to log a message on a certain loglevel
void log(String message, CacheManagerLogLevel level) {
if (CacheManager.logLevel.index >= level.index) {
// ignore: avoid_print
print(message);
}
}
Expand Down
1 change: 1 addition & 0 deletions flutter_cache_manager/lib/src/result/file_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter_cache_manager/src/result/file_response.dart';
///Released under MIT License.

/// Enum for whether the file is coming from the cache or is just downloaded.
// ignore: constant_identifier_names
enum FileSource { NA, Cache, Online }

/// FileInfo contains the fetch File next to some info on the validity and
Expand Down
1 change: 0 additions & 1 deletion flutter_cache_manager/lib/src/web/web_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:flutter_cache_manager/src/result/file_response.dart';
import 'package:flutter_cache_manager/src/storage/cache_object.dart';
import 'package:flutter_cache_manager/src/web/file_service.dart';
import 'package:flutter_cache_manager/src/web/queue_item.dart';
import 'package:pedantic/pedantic.dart';
import 'package:rxdart/rxdart.dart';
import 'package:uuid/uuid.dart';

Expand Down
2 changes: 1 addition & 1 deletion flutter_cache_manager/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies:
http: ^0.13.0
path: ^1.8.0
path_provider: ^2.0.0
pedantic: ^1.10.0
rxdart: ">=0.26.0 <0.28.0"
sqflite: ^2.0.0+3
uuid: ^3.0.0
Expand All @@ -25,3 +24,4 @@ dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^5.0.0
flutter_lints: ^1.0.4
4 changes: 1 addition & 3 deletions flutter_cache_manager/test/cache_manager_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:async';
import 'dart:typed_data';
import 'dart:ui';

import 'package:clock/clock.dart';
import 'package:file/memory.dart';
Expand Down Expand Up @@ -490,8 +489,7 @@ void main() {
var fileUrl = 'baseflow.com/test';

var store = MockCacheStore();
when(store.putFile(argThat(anything)))
.thenAnswer((_) => Future.value(VoidCallback));
when(store.putFile(argThat(anything))).thenAnswer((_) => Future.value());

when(store.getFile(fileUrl)).thenAnswer((_) => Future.value(null));

Expand Down
10 changes: 5 additions & 5 deletions flutter_cache_manager/test/cache_object_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ void main() {
final validDate = DateTime.utc(2020, 03, 27, 09, 26).toLocal();
final now = DateTime(2020, 03, 28, 09, 26);

final testId = 1;
final relativePath = 'test.png';
final testUrl = 'www.test.com/image';
final testKey = 'test123';
final eTag = 'test1';
const testId = 1;
const relativePath = 'test.png';
const testUrl = 'www.test.com/image';
const testKey = 'test123';
const eTag = 'test1';

test('constructor, no explicit key', () {
final object = CacheObject(
Expand Down
2 changes: 1 addition & 1 deletion flutter_cache_manager/test/helpers/json_repo_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class JsonRepoHelpers {
}

static final defaultValidTill = clock.now().add(const Duration(days: 7));
static final defaultRelativePath = 'test.png';
static const defaultRelativePath = 'test.png';
static final List<CacheObject> startCacheObjects = [
// Old object
CacheObject(
Expand Down
4 changes: 1 addition & 3 deletions flutter_cache_manager/test/web_helper_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:ui';

import 'package:clock/clock.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
Expand Down Expand Up @@ -232,8 +231,7 @@ void main() {

MockCacheStore _createStore(Config config) {
final store = MockCacheStore();
when(store.putFile(argThat(anything)))
.thenAnswer((_) => Future.value(VoidCallback));
when(store.putFile(argThat(anything))).thenAnswer((_) => Future.value());
when(store.retrieveCacheData(argThat(anything)))
.thenAnswer((invocation) => Future.value(CacheObject(
invocation.positionalArguments.first as String,
Expand Down