0
0
mirror of https://git.code.sf.net/p/opencamera/code.git synced 2024-09-19 19:42:29 +02:00

Suppress some warning types.

This commit is contained in:
Mark Harman 2020-02-27 00:30:37 +00:00
parent 4960a3b346
commit dd6551992e
4 changed files with 69 additions and 2 deletions

5
.gitignore vendored
View File

@ -8,7 +8,10 @@ _other/
_saved/
.gradle/
.idea/
.idea/*
!.idea/inspectionProfiles
build/
app/release/
gfx/

View File

@ -0,0 +1,37 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AndroidLintUnusedResources" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="BooleanMethodIsAlwaysInverted" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ConstantConditions" enabled="false" level="WARNING" enabled_by_default="false">
<option name="SUGGEST_NULLABLE_ANNOTATIONS" value="false" />
<option name="DONT_REPORT_TRUE_ASSERT_STATEMENTS" value="false" />
</inspection_tool>
<inspection_tool class="EmptyMethod" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="EmptyStatementBody" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_reportEmptyBlocks" value="true" />
</inspection_tool>
<inspection_tool class="PointlessBooleanExpression" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_ignoreExpressionsContainingConstants" value="true" />
</inspection_tool>
<inspection_tool class="SameParameterValue" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="TrivialIf" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="UnnecessaryLocalVariable" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_ignoreImmediatelyReturnedVariables" value="true" />
<option name="m_ignoreAnnotatedVariables" value="false" />
</inspection_tool>
<inspection_tool class="UnusedReturnValue" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="unused" enabled="true" level="WARNING" enabled_by_default="true" method="protected" parameter="protected">
<option name="LOCAL_VARIABLE" value="true" />
<option name="FIELD" value="true" />
<option name="METHOD" value="true" />
<option name="CLASS" value="true" />
<option name="PARAMETER" value="true" />
<option name="REPORT_PARAMETER_FOR_PUBLIC_METHODS" value="false" />
<option name="ADD_MAINS_TO_ENTRIES" value="true" />
<option name="ADD_APPLET_TO_ENTRIES" value="true" />
<option name="ADD_SERVLET_TO_ENTRIES" value="true" />
<option name="ADD_NONJAVA_TO_ENTRIES" value="true" />
</inspection_tool>
</profile>
</component>

View File

@ -23,6 +23,13 @@ copy %src%\app\build.gradle %dst%\app\
mkdir %dst%\gradle
xcopy %src%\gradle %dst%\gradle /E /Y
REM We copy the inspectionProfiles as this stores which Android inspection warnings/errors we've disabled; although
REM note this isn't part of the Git repository, due lots of other files in .idea/ that we don't want to be part of the
REM project.
mkdir %dst%\.idea
mkdir %dst%\.idea\inspectionProfiles
xcopy %src%\.idea\inspectionProfiles %dst%\.idea\inspectionProfiles /E /Y
mkdir %dst%\_docs
REM xcopy %src%\_docs %dst%\_docs /E /Y
copy %src%\_docs\credits.html %dst%\_docs

View File

@ -19,6 +19,26 @@ Preview: At a higher level, you might want to take the classes in Preview/ as we
Application: You might prefer to use Open Camera in its entirety, as an Activity within your application (or possibly converting the MainActivity to a fragment). Consider whether Open Camera's Settings should be unified with the settings in your application. Accesses to SharedPreferences use the PreferencesKeys class to find the keys.
Android inspection warnings/errors
==================================
The file .idea/inspectionProfiles/Project_Default.xml contains settings for Android inpsections (see Editor/Inspections). The following have been disabled:
* AndroidLintUnusedResources - seems to give false information on res/ images, as well as complaining about renderscript files in build folders.
* BooleanMethodIsAlwaysInverted - Generates too many useless warnings.
* ConstantConditions - Unfortunately this seems broken when calling an Android SDK function where only a stub source is available, such that the inspection incorrectly things an exception is thrown. E.g., see calls to TouchUtils.clickView() in MainActivityTest, this inspection thinks that e.g. "i<8" in for loops is always true.
* EmptyMethod - Sometimes can be useful to explicitly have a subclassed empty method, to show I've intentionally left it empty rather than forgotten to consider it.
* EmptyStatementBody - These may be intentional.
* PointlessBooleanExpression - This complains too much about controlling codepaths with final boolean flags (e.g., "if( debug_switch && blah )").
* SameParameterValue - A parameter may have been provided for future proofing even if callers currently only use one value.
* TrivialIf - This suggests replacing clear if statements with shorter but more convoluted boolean expressions.
* UnusedReturnValue - In some cases a function may return something even if not currently used, either for future proofing, or we used it in the past (and might use again in the future). Whilst a caller not checking the return can be an error, this check wouldn't pick that up so long as at least one caller checked the return.
The following are enabled, but with modifications:
* UnnecessaryLocalVariable - m_ignoreImmediatelyReturnedVariables is true.
* unused - parameter="protected", REPORT_PARAMETER_FOR_PUBLIC_METHODS is false (otherwise this complaints about parameters in overriden methods being unused); method="protected" (in some cases public unused methods may be added for future proofing).
Licence
=======
@ -30,4 +50,4 @@ Homepage: http://opencamera.org.uk/
Google Play download: https://play.google.com/store/apps/details?id=net.sourceforge.opencamera
Mark Harman 9 September 2018
Mark Harman 27 February 2020