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

feat: Implement file adapter #16

Closed
wants to merge 3 commits into from
Closed

feat: Implement file adapter #16

wants to merge 3 commits into from

Conversation

ctrysbita
Copy link
Contributor

This pull request implements:

  • Milestone 1
    • adapter
    • file adapter

Full tests will be delayed until the implementation of model.

@ctrysbita ctrysbita changed the title Implement file adapter feat: Implement file adapter Apr 14, 2021
Signed-off-by: Jason C.H <ctrysbita@outlook.com>
Signed-off-by: Jason C.H <ctrysbita@outlook.com>
Signed-off-by: Jason C.H <ctrysbita@outlook.com>
@hsluoyz hsluoyz requested a review from KNawm April 14, 2021 07:40
@hsluoyz
Copy link
Member

hsluoyz commented Apr 14, 2021

@KNawm

@ctrysbita ctrysbita mentioned this pull request Apr 14, 2021
7 tasks
///
/// [model] is the model.
void loadPolicy(Model model);
Future<void> loadPolicy(Model model);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remove the comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments are copied from Go and TS implementation.
Some modification was made because dart doesn't suggest comment start with function name and also tagged document for each paramenter. Especially meaningless doc like "[model] is the model".

See also: https://dart.dev/guides/language/effective-dart/documentation#do-use-prose-to-explain-parameters-return-values-and-exceptions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course the documents still can be improved. I prefer to do them together with other documents (Milestone 6).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the params from the comments do more harm than good IMHO, you can refactor them into prose but I think it's better to have them until then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will try to refactor them into prose.

// See the License for the specific language governing permissions and
// limitations under the License.

import '../model/model.dart';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to be consistent with the style used in this file and others, if you think package imports are too verbose feel free to change them into relative imports but do so in a separate PR and refactor all of the codebase so it won't be inconsistent.

Copy link
Contributor Author

@ctrysbita ctrysbita Apr 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also: https://dart-lang.github.io/linter/lints/prefer_relative_imports.html
I'm going to change all of them in following prs XD

Comment on lines +1 to +13
// Copyright 2018-2021 The Casbin Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the license on each file @hsluoyz? If so, I would suggest opening a PR exclusively for this change on all files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Opening a PR for this is good.

}

@override
void removeFilteredPolicy(
String sec, String ptype, int fieldIndex, List<String> fieldValues) {
// TODO: implement removeFilteredPolicy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better to keep the TODO until we implement this, so we can keep track easily.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

@override
void removePolicy(String sec, String ptype, List<String> rule) {
// TODO: implement removePolicy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

}

@override
void savePolicy(Model model) {
// TODO: implement savePolicy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@ctrysbita ctrysbita closed this May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants