Office Hours — Today, September 26

Tuesday, September 24

Mark M.
has entered the room
Mark M.
turned on guest access
Sep 26
8:45 AM
Scott W.
has entered the room
Scott W.
Hello Mark
Mark M.
hello, Scott!
how can I help you today?
Scott W.
I've got a lint question
Mark M.
I try to clean my dryer trap at least once a week
Scott W.
;)
my coffee is ready. brb
ok
8:50 AM
Scott W.
In Android Studio, you can click on Analyze and then Inspect Code and it'll give all these great warnings
they are split into categories: Android, General, Java, XML, ...
I have a lint.xml file that specifies a certain warning should be treated as an error
specifically UnusedResources
Mark M.
OK
Scott W.
I want to add other issues to the list and mark them as errors, but they are not available. I want to add Android warnings to the list
but it seems to only work with Java warnings
Mark M.
I am not certain what you mean by "Android warnings" and "Java warnings". Are you referring to those code inspections that you mentioned earlier?
Scott W.
correct
Mark M.
basically, there are two systems for static code analysis at play here: Lint and Android Studio/IDEA code inspections
Lint is available from outside of the IDE; code inspections are not
Scott W.
ok
Mark M.
and lint.xml is for Lint
Scott W.
I see
Mark M.
it's kinda confusing
Scott W.
well, how can I fail builds for these various code inspections?
8:55 AM
Mark M.
see if there is an equivalent Lint rule, or create a Lint rule, or use some other tool that supplies that sort of analysis
if all you want to do is fail builds in the IDE, you can adjust the behavior of the inspection
but I am assuming that you want to fail builds everywhere (e.g., CI server)
Scott W.
well failing them locally would be a good first step
Mark M.
in Settings > Inspections, you can choose the severity level for a given inspection
I don't know if that will "fail the build", but it at least affects color-coding
Scott W.
when I choose Run 'app', I want it to say "NO"
I'll play around with those settings and see what that does.
Mark M.
sorry, but I have not played with changing inspection severities to know for certain if it will block the build
my knowledge of this stuff comes mostly in the area of filing bug reports
if I file it against Lint, it's almost guaranteed to actually be a code inspection
if I file it against Studio, it's almost guaranteed to be really a Lint issue
9:00 AM
Scott W.
ok changing the severity adds a red squiggle under the relevant bit of code, but no fail.
Mark M.
I was afraid that might be the case
Scott W.
we use Travis for CI. Is it possible that Travis can use some other code inspection tool and catch this stuff?
Mark M.
well, there are a variety of static analysis tools for Java and Kotlin
those that integrate into Gradle can fail the build
9:05 AM
Mark M.
for example, ktlint confirms that your Kotlin code adheres to the official style, and rxlint confirms that you have error handlers on all your RxJava chains
you can also create custom Lint rules, though that is not well documented
Scott W.
yeah that's a bit more involved than I want to get into right now.
I'm going to tinker around in Android Studio and see what I can get done.
9:10 AM
Scott W.
Is there a way to run the Android Studio code inspection from the command line?
Mark M.
AFAIK, no
however, Studio is really using IDEA here, so you might hunt around to see if there is an IDEA solution that happens to work with Studio
Scott W.
good tip. I'm getting somewhere now
9:20 AM
Scott W.
ok I've got it doing the inspection from the command line. However, Android Studio can't be open when I run the command.
Mark M.
that might still be OK for Travis, though
Scott W.
well will Travis have Android Studio though?
Mark M.
CI servers are usually servers
Scott W.
this relies on an sh file packaged with Android Studio
Mark M.
ah, I see
you'd need to decipher enough of that shell script to see what it depends on
most likely, it uses Java and some JARs from the IDE
so while the Travis server won't have Studio, if it is your own server, you could arrange to either get Studio there or at least get those JARs there
if this is a hosted CI-as-a-service thing, though, you would have to see what options they have for this level of customization
Scott W.
I see. I'll talk to the guy that manages Travis about that.
9:25 AM
Mark M.
hopefully the guy that manages Travis is not named Travis, as that would get confusing
Scott W.
Thanks for the guidance!
Mark M.
you're welcome!
Scott W.
:)
talk to ya later
Mark M.
have a pleasant day!
Scott W.
has left the room
9:30 AM
Mark M.
turned off guest access

Tuesday, September 24

 

Office Hours

People in this transcript

  • Mark Murphy
  • Scott Wehby