-
-
Notifications
You must be signed in to change notification settings - Fork 360
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
Add Android Linting Example #3931
base: main
Are you sure you want to change the base?
Conversation
@c0d33ngr looks good, need to include an example test and explanation so we can include it in the documentation |
@c0d33ngr Buddy you did just basic linting but this is not the appropriate way tbh i have tried this on my example and its saying the miss of class file but class files only come after the compilation so @lihaoyi i request you to please wait till my new pull request(anndroid bundle support) gets merged coz in that i have updated the whole android app building process and made it professional (now we can include custom resources) so @c0d33ngr sorry to interrupt you, but please understand... |
@himanshumahajan138 completing bounties out of order is fine. I'll look at your PR if you wish and we can decide which one to merge first |
Ya I Agree We can decide which one to merge first i was saying before becoz there will be need for updated code as you can see in my pr i have updated the codes with resources so that's the only thing i was concerned about rest we can decide this... |
@lihaoyi this command below produce the error output above. What could be wrong? |
@c0d33ngr the lint error should be fixed in latest main branch, if you merge in main it should work. Give me some time to do a proper review, I'm not familiar with android haha |
FYI I'm planning on landing #3935 first before coming back to this, since that one is a larger and more invasive PR so this one would be easier to rebase/merge after |
Took a review pass. Looks like a straightforward change but left a few nits |
I'll do the necessary changes and also include more features to it. I had to rewrite it as a module after looking through java linting in the codebase and also other android related modules |
I was ill so I couldn't resolve the issues pointed out from code review on time but I'm good now |
I think this looks good. @0xnm I don't know if you want to glance over this before I merge it |
Hi @lihaoyi took a break off the issue fro sometime, now working on it I want to ask how to use
Got something like this as error
|
@c0d33ngr |
Okay thank you, trying it out |
@0xnm please review when less busy. I've done the changes you requested Also, to make use of
|
Hi @0xnm do you have any idea to why the lint cli tool couldn't spot the it? |
I suggest you to check the arguments you are calling |
Okay... I'll look into that What think of the PR any changes needed? |
Hi @0xnm , the suggestion you gave work. It was the You can review when less busy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks reasonable to me. This first drop of lint support doesn't obviously support all the configuration options available in AGP and options supported by the tool, but it is a reasonable basis for doing a simple lint run.
One more handy thing to have is maybe to provide module-independent runner/report collector (see existing verification tooling modules in the codebase, they have static methods with Evaluator
), but it is not a blocker for me.
I left some comments, for the rest I think @lihaoyi can do a review.
@@ -11,7 +11,6 @@ | |||
** xref:javalib/publishing.adoc[] | |||
** xref:javalib/build-examples.adoc[] | |||
** xref:javalib/web-examples.adoc[] | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably a change to rollback? seems like this was a separator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please I do not fully understand what you meant here
|
||
> ./mill app.androidLintRun | ||
|
||
> ls out/app/androidLintRun.dest # Display full path to the linting report in text file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it is not only txt file, but also html
// produces a detailed HTML report by default, identifying potential issues in the code, such as performance, | ||
// security, and usability warnings. This helps maintain the health and quality of the codebase. | ||
|
||
// In this example, we set a custom config to generate the report file in txt format and not HTML. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually HTML is generated as well
// == Linting with Custom Configurations | ||
|
||
// The commands below are demos on using `androidLintRun` task with some custom configuratins on a sample project. | ||
// The demos are adjusting severity lelvel of linting issue, enable and disable linting issue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// The demos are adjusting severity lelvel of linting issue, enable and disable linting issue | |
// The demos are adjusting severity level of linting issue, enable and disable linting issue |
* Specifies the file format(s) of the lint report. Available file formats are defined in AndroidLintReportFormat, | ||
* such as AndroidLintReportFormat.Html, AndroidLintReportFormat.Xml, AndroidLintReportFormat.Txt, and AndroidLintReportFormat.Sarif. | ||
*/ | ||
def androidLintReportFmt: T[Seq[AndroidLintReportFormat.Value]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if fmt
is used in this codebase as a word, it seems it is rather format
which is widely used.
val cp = runClasspath().map(_.path).filter(os.exists).mkString(":") | ||
|
||
// Set path to the location of the project source codes | ||
val src = sources().map(_.path / "main" / "java").filter(os.exists).mkString(":") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you shouldn't hardcode path as main/java
, because both pieces can be actually different. I would suggest to use Lib.findSourceFiles
(extension can be both .java
and .kotlin
) at least with the given sources
.
Ideally, in order to not have a huge path with each individual files there, it should be a way to find a common roots for the given set of the files, but I don't know if there are utility methods in the project's codebase to compute that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed directory path to the sources file that's why I did that using the most common /src/main/java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actual files can be under any path of sources()
root, so hardcoding main/java
doesn't work: nothing prevents having source files under sources()/foo/bar/foobar
, for example.
This is meant to to be a draft of item number 4 of issue #3868. The android linting
Hi @lihaoyi is this close to what you have in mind about the android linting or there's more?