Skip to content

Commit

Permalink
Re-enable custom lint, update lint rules and fix docs (#2335)
Browse files Browse the repository at this point in the history
* update talawa_lint

* update talawa_lint
  • Loading branch information
literalEval authored Jan 21, 2024
1 parent cbfd313 commit be0e3fa
Show file tree
Hide file tree
Showing 44 changed files with 373 additions and 311 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- name: Analysing codebase for default linting
run: flutter analyze --no-pub
- name: Analysing codebase for custom linting
run: flutter pub run custom_lint
run: dart run custom_lint
- name: Changed Files
id: changed-files
uses: tj-actions/changed-files@v41
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Analysing codebase for default linting
run: flutter analyze --no-pub
- name: Analysing codebase for custom linting
run: flutter pub run custom_lint
run: dart run custom_lint
# - name: Echo the GitHub environment for troubleshooting
# run: echo "$GITHUB_CONTEXT"
# - name: Echo the GitHub context for troubleshooting
Expand Down
4 changes: 2 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ analyzer:
- test/helpers/test_helpers.mocks.dart

plugins:
custom_lint
- custom_lint

custom_lint:
rules:
- talawa_lint

exclude:
- test/
- test

linter:
rules:
Expand Down
7 changes: 0 additions & 7 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ import 'package:talawa/view_model/lang_view_model.dart';
import 'package:talawa/view_model/theme_view_model.dart';
import 'package:talawa/views/base_view.dart';

/// First function to initialize the application, invoked automatically.
///
/// **params**:
/// None
///
/// **returns**:
/// * `Future<void>`: resolves if the application was successfully initialized.
Future<void> main() async {
// Returns an instance of the binding that implements WidgetsBinding.
WidgetsFlutterBinding.ensureInitialized();
Expand Down
2 changes: 1 addition & 1 deletion lib/models/app_tour.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AppTour {
/// **params**:
/// * `onClickTarget`: Its a function which is required to run desired tasks on click.
/// * `onFinish`: Its a function which is required to run desired tasks on finish
///
/// * `targets`: [FocusTargets] to show the tour on.
///
/// **returns**:
/// None
Expand Down
4 changes: 4 additions & 0 deletions lib/models/asymetric_keys/asymetric_keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ part 'asymetric_keys.g.dart';

// This model is created to save Asymmetric Keys to the Hive as Hive doesn't allow to store objects other than Arrays, List, int, Strings etc.
@HiveType(typeId: 7)

/// Hive Type for [AssymetricKeys].
class AsymetricKeys extends HiveObject {
AsymetricKeys({required this.keyPair});
@HiveField(0)

/// The key pair to work with.
final AsymmetricKeyPair<PublicKey, PrivateKey> keyPair;
}
2 changes: 1 addition & 1 deletion lib/plugins/fetch_plugin_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FetchPluginList {
/// None
///
/// **returns**:
/// * `Future<void>`: it returns Future of void
/// None
Future<void> fetchList() async {
late final GraphQLClient client = graphqlConfig.clientToQuery();
final QueryResult result = await client.query(
Expand Down
9 changes: 3 additions & 6 deletions lib/services/chat_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class ChatService {
/// * `messageContent`: The content of the message to be sent.
///
/// **returns**:
/// * `Future<void>`: A promise that will be fulfilled
/// when the message is successfully sent.
/// None
Future<void> sendMessageToDirectChat(
String chatId,
String messageContent,
Expand All @@ -96,8 +95,7 @@ class ChatService {
/// None
///
/// **returns**:
/// * `Future<void>`: A promise that will be fulfilled
/// when the direct chats are successfully retrieved.
/// None
Future<void> getDirectChatsByUserId() async {
final userId = _userConfig.currentUser.id;

Expand Down Expand Up @@ -129,8 +127,7 @@ class ChatService {
/// are to be retrieved.
///
/// **returns**:
/// * `Future<void>`: A promise that will be fulfilled
/// when the chat messages are successfully retrieved.
/// None
Future<void> getDirectChatMessagesByChatId(chatId) async {
// trigger graphQL query to get all the chat messages
// of a particular chat using [chatId].
Expand Down
2 changes: 1 addition & 1 deletion lib/services/comment_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CommentService {
/// * `text`: The comment text.
///
/// **returns**:
/// * `Future<void>`: promise that will be fulfilled message background activities are successful.
/// None
Future<void> createComments(String postId, String text) async {
final String createCommentQuery = CommentQueries().createComment();
final result = await _dbFunctions.gqlAuthMutation(
Expand Down
4 changes: 2 additions & 2 deletions lib/services/event_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class EventService {
/// None
///
/// **returns**:
/// * `Future<void>`: void
/// None
Future<void> getEvents() async {
// refresh user's access token
await _dbFunctions.refreshAccessToken(userConfig.currentUser.refreshToken!);
Expand Down Expand Up @@ -156,7 +156,7 @@ class EventService {
/// * `variables`: this will be `map` type and contain all the event details need to be update.
///
/// **returns**:
/// * `Future<void>`: void return
/// None
Future<void> editEvent({
required String eventId,
required Map<String, dynamic> variables,
Expand Down
1 change: 1 addition & 0 deletions lib/services/post_service.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore_for_file: talawa_good_doc_comments, talawa_api_doc
import 'dart:async';

import 'package:graphql_flutter/graphql_flutter.dart';
Expand Down
9 changes: 3 additions & 6 deletions lib/services/task_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class TaskService {
/// are to be retrieved.
///
/// **returns**:
/// * `Future<void>`: A promise that will be fulfilled after
/// tasks for the event are retrieved.
/// None
Future<void> getTasksForEvent(String eventId) async {
await _databaseMutationFunctions
.refreshAccessToken(_userConfig.currentUser.refreshToken!);
Expand All @@ -56,8 +55,7 @@ class TaskService {
/// None
///
/// **returns**:
/// * `Future<void>`: A promise that will be fulfilled after
/// the user's tasks are retrieved.
/// None
Future<void> getTasksByUser() async {
await _databaseMutationFunctions
.refreshAccessToken(_userConfig.currentUser.refreshToken!);
Expand Down Expand Up @@ -165,8 +163,7 @@ class TaskService {
/// * `creatorId`: The ID of the task's creator.
///
/// **returns**:
/// * `Future<void>`: A promise that will be fulfilled
/// after the task deletion process completes.
/// None
Future<void> deleteTask(String taskId, String creatorId) async {
if (creatorId == _userConfig.currentUser.id) {
await _databaseMutationFunctions
Expand Down
6 changes: 4 additions & 2 deletions lib/splash_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ class _SplashScreenState extends State<SplashScreen> {
// / `_handleInitialUri` is an async function that is used to hanlde
// / the initial uri of the application.

/// Opening a URL displays that screen in your app, `_handleInitialUri` is an async function that is used to handle the initial uri of the application.
/// Opening a URL displays that screen in your app.
///
/// Used to handle the initial uri of the application.
///
/// **params**:
/// None
///
/// **returns**:
/// * `Future<void>`: resolves when the check for userLoggedin is complete or not
/// None
Future<void> _handleInitialUri() async {
_sub = uriLinkStream.listen(
(Uri? uri) {
Expand Down
15 changes: 9 additions & 6 deletions lib/utils/encryptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,24 @@ class Encryptor {
///
/// **params**:
/// * `keyPair`: [AsymmetricKeyPair] to save.
/// * `hive`: The [HiveInterface] to store keys in.
///
/// **returns**:
/// * `Future<void>`: None
/// None
Future<void> saveKeyPair(
AsymmetricKeyPair<PublicKey, PrivateKey> keyPair,
HiveInterface hiveInterface,
HiveInterface hive,
) async {
// TODO: Implement secure storage here
final Box<AsymetricKeys> keysBox =
await hiveInterface.openBox<AsymetricKeys>('user_keys');
await hive.openBox<AsymetricKeys>('user_keys');
keysBox.put('key_pair', AsymetricKeys(keyPair: keyPair));
}

/// Loads secret keys from the Hive db.
///
/// **params**:
/// None
/// * `hive`: The [HiveInterface] to load keys from.
///
/// **returns**:
/// * `Future<AsymmetricKeyPair<PublicKey, PrivateKey>>`: The public and
Expand Down Expand Up @@ -127,6 +128,8 @@ class Encryptor {
return String.fromCharCodes(decryptedBytes);
}

// TODO: Use this somewhere

/// Helper function to decrypt the message.
///
/// Internally uses the [loadKeyPair] function to get private key and
Expand All @@ -135,10 +138,10 @@ class Encryptor {
/// **params**:
/// * `message`: Message object containing a field named [encryptedMessage]
/// which is supposed to contained user's message in encrypted format.
/// * `hive`: The [HiveInterface] to store things in.
///
/// **returns**:
/// * `Future<void>`: None
/// TODO: Use this somewhere
/// None
Future<void> receiveMessage(
Map<String, dynamic> message,
HiveInterface hive,
Expand Down
8 changes: 4 additions & 4 deletions lib/view_model/access_request_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ class AccessScreenViewModel extends BaseModel {
/// text controller for optional message during the request.
final optionalMessageController = TextEditingController();

/// initialization function.
/// Initialization function.
///
/// **params**:
/// * `org`: Org to send request to.
///
/// **returns**:
/// * `Future<void>`: None
/// None
Future<void> initialise(OrgInfo org) async {
selectedOrganization = org;
}

/// sending member ship request function.
/// Sending member ship request function.
///
/// **params**:
/// None
///
/// **returns**:
/// * `Future<void>`: define_the_return
/// None
Future<void> sendMembershipRequest() async {
//TODO: Implement Message arg for below function
final result = await databaseFunctions.gqlAuthMutation(
Expand Down
Loading

0 comments on commit be0e3fa

Please sign in to comment.