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

implement quick_fix for talawa_good_doc and enforce tab before None of params block #1754

Merged
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
2 changes: 1 addition & 1 deletion lib/locator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ final imagePicker = locator<ImagePicker>();
/// This function registers the widgets/objects in "GetIt".
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// None
Expand Down
6 changes: 3 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
/// First function to initialize the application, invoked automatically.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// * `Future<void>`: resolves if the application was successfully initialized.
Expand Down Expand Up @@ -201,7 +201,7 @@ class _MyAppState extends State<MyApp> {
/// It allows to manage and interact with the application’s home screen quick actions.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// None
Expand Down Expand Up @@ -333,7 +333,7 @@ class DemoViewModel extends BaseModel {
/// Set up firebase instance, enbables messaging,listens to icoming messages.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// * `Future<void>`: promise that will be fulfilled Firebase is setted up.
Expand Down
6 changes: 3 additions & 3 deletions lib/models/post/post_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Post {
/// this is to get duration of post.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// * `String`: date is returned in ago form.
Expand Down Expand Up @@ -117,7 +117,7 @@ class LikedBy {
/// Convert dart object to json.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// * `Map<String, dynamic>`: json is returned.
Expand Down Expand Up @@ -151,7 +151,7 @@ class Comments {
/// Convert dart object to json.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// * `Map<String, dynamic>`: json is returned.
Expand Down
6 changes: 3 additions & 3 deletions lib/services/event_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class EventService {
/// This function is used to set stream subscription for an organization.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// None
Expand All @@ -65,7 +65,7 @@ class EventService {
/// This function is used to fetch all the events of an organization.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// * `Future<void>`: void
Expand Down Expand Up @@ -184,7 +184,7 @@ class EventService {
/// This function is used to cancel the stream subscription of an organization.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// None
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/post_queries.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class PostQueries {
/// Add Like to a post.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// * `String`: The query related to addingLike
Expand All @@ -61,7 +61,7 @@ class PostQueries {
/// Remove Like from a post.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// * `String`: The query related to removingLike
Expand All @@ -82,7 +82,7 @@ class PostQueries {
/// Upload a post to database.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// * `String`: The query related to uploadingPost.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class AddPostViewModel extends BaseModel {
/// This function is usedto do initialisation of stuff in the view model.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// None
Expand Down Expand Up @@ -110,7 +110,7 @@ class AddPostViewModel extends BaseModel {
/// This function uploads the post finally, and navigate the success message or error message in Snack Bar.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// * `Future<void>`: Uploading post by contacting queries
Expand Down Expand Up @@ -146,7 +146,7 @@ class AddPostViewModel extends BaseModel {
/// This function removes the image selected.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class CreateEventViewModel extends BaseModel {
/// Function To Initialize.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// None
Expand All @@ -134,7 +134,7 @@ class CreateEventViewModel extends BaseModel {
/// for creating an event and passes the required variables for the event.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// * `Future<void>`: Asynchronous function for creating event
Expand Down Expand Up @@ -224,7 +224,7 @@ class CreateEventViewModel extends BaseModel {
/// This function remove the selected image.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// None
Expand All @@ -236,7 +236,7 @@ class CreateEventViewModel extends BaseModel {
/// This function fetch all the users in the current organization and return `List`.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// * `Future<List<User>>`: Current Organization Users List
Expand All @@ -258,7 +258,7 @@ class CreateEventViewModel extends BaseModel {
/// This function build the user list.
///
/// **params**:
/// None
/// None
///
/// **returns**:
/// None
Expand Down
25 changes: 25 additions & 0 deletions talawa_lint/lib/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/syntactic_entity.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';

Expand Down Expand Up @@ -138,3 +139,27 @@ bool isMethod(ClassMember m) => m is MethodDeclaration;
bool isPrivate(Token? name) =>
// ignore: avoid_bool_literals_in_conditional_expressions
name != null ? Identifier.isPrivateName(name.lexeme) : false;

class TalawaLintHelpers {
static bool isVoid(Declaration node) {
return ((node is FunctionDeclaration)
? node.returnType?.type!.isVoid
: (node as MethodDeclaration).returnType?.type!.isVoid) ??
true;
}

static bool isImplicitReturn(Declaration node) {
return ((node is FunctionDeclaration)
? node.declaredElement?.hasImplicitReturnType
: (node as MethodDeclaration)
.declaredElement
?.hasImplicitReturnType) ??
false;
}

static DartType? returnType(Declaration node) {
return (node is FunctionDeclaration)
? node.returnType?.type
: (node as MethodDeclaration).returnType?.type;
}
}
78 changes: 78 additions & 0 deletions talawa_lint/lib/talawa_api_doc/talawa_api_doc.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import 'package:analyzer/error/listener.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';
import 'package:talawa_lint/talawa_api_doc/talawa_api_doc_fixer.dart';
import 'package:talawa_lint/talawa_api_doc/talawa_api_doc_visitor.dart';

class TalawaApiDocLintRule extends DartLintRule {
const TalawaApiDocLintRule() : super(code: _code);

/// Metadata about the warning that will show-up in the IDE.
/// This is used for `// ignore: code` and enabling/disabling the lint
static const _code = LintCode(
name: 'talawa_api_doc',
problemMessage: 'No documentation found for this field.',
correctionMessage: "Add a valid documentation describing usecase.",
url: "https://docs.talawa.io/docs/developers/talawa/talawa-lint/",
);

@override
void run(
CustomLintResolver resolver,
ErrorReporter reporter,
CustomLintContext context,
) {
final visitor = TalawaApiDocVisitor(
this,
context,
reporter,
);

context.registry.addClassDeclaration(
(node) => node.visitChildren(visitor),
);
context.registry.addClassTypeAlias(
(node) => node.visitChildren(visitor),
);
context.registry.addCompilationUnit(
(node) => node.visitChildren(visitor),
);
context.registry.addConstructorDeclaration(
(node) => node.visitChildren(visitor),
);
context.registry.addEnumConstantDeclaration(
(node) => node.visitChildren(visitor),
);
context.registry.addEnumDeclaration(
(node) => node.visitChildren(visitor),
);
context.registry.addExtensionDeclaration(
(node) => node.visitChildren(visitor),
);
context.registry.addFieldDeclaration(
(node) => node.visitChildren(visitor),
);
context.registry.addFunctionDeclaration(
(node) => visitor.check(node),
);
context.registry.addFunctionTypeAlias(
(node) => node.visitChildren(visitor),
);
context.registry.addGenericTypeAlias(
(node) => node.visitChildren(visitor),
);
context.registry.addMixinDeclaration(
(node) => node.visitChildren(visitor),
);
context.registry.addVariableDeclaration(
(node) => node.visitChildren(visitor),
);
context.registry.addTopLevelVariableDeclaration(
(node) => node.visitChildren(visitor),
);
}

@override
List<Fix> getFixes() => [
TalawaAPIDocFixer(),
];
}
Loading