diff --git a/.gitignore b/.gitignore
index a7d27fb6c3..edd8062e07 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,4 +41,4 @@ maka-vlc/
/fastlane/report.xml
/fastlane/README.md
-findbugs-report
+reports
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 7f35ca1db0..7e1e325dd0 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -3,7 +3,8 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply from: '../code_quality_tools/jacoco.gradle'
-apply from: '../code_quality_tools/quality.gradle'
+apply from: '../code_quality_tools/findbugs.gradle'
+apply from: '../code_quality_tools/checkstyle.gradle'
def globalConf = rootProject.ext
android {
diff --git a/code_quality_tools/checkstyle-noframes-sorted.xsl b/code_quality_tools/checkstyle-noframes-sorted.xsl
new file mode 100644
index 0000000000..6b884f19ce
--- /dev/null
+++ b/code_quality_tools/checkstyle-noframes-sorted.xsl
@@ -0,0 +1,177 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+ CheckStyle Audit |
+
+
+ Designed for use with CheckStyle and Ant. |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Files
+
+
+ Name |
+ Errors |
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+
+
+
+
+
+ File
+
+
+
+ Error Description |
+ Line |
+
+
+
+
+
+ |
+ |
+
+
+
+ Back to top
+
+
+
+
+ Summary
+
+
+
+
+ Files |
+ Errors |
+
+
+
+ |
+ |
+
+
+
+
+
+
+ a
+ b
+
+
+
\ No newline at end of file
diff --git a/code_quality_tools/checkstyle.gradle b/code_quality_tools/checkstyle.gradle
new file mode 100644
index 0000000000..ec234850a0
--- /dev/null
+++ b/code_quality_tools/checkstyle.gradle
@@ -0,0 +1,22 @@
+apply plugin: 'checkstyle'
+
+checkstyle {
+ configFile file("${project.rootDir}/code_quality_tools/checkstyle.xml")
+ ignoreFailures false
+ showViolations true
+ configProperties = [
+ 'checkstyle.cache.file': file('${project.rootDir}/reports/checkstyle/checkstyle.cache'),
+ ]
+}
+
+task checkstyle(type: Checkstyle) {
+ source 'src/main', 'src/release'
+ include '**/*.java'
+ exclude '**/gen/**'
+ exclude '**/R.java'
+ exclude '**/BuildConfig.java'
+ reports {
+ html.destination "${project.rootDir}/reports/checkstyle/main.html"
+ }
+ classpath = files()
+}
\ No newline at end of file
diff --git a/code_quality_tools/checkstyle.xml b/code_quality_tools/checkstyle.xml
new file mode 100644
index 0000000000..9611c3032a
--- /dev/null
+++ b/code_quality_tools/checkstyle.xml
@@ -0,0 +1,128 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code_quality_tools/quality.gradle b/code_quality_tools/findbugs.gradle
similarity index 78%
rename from code_quality_tools/quality.gradle
rename to code_quality_tools/findbugs.gradle
index f47e5b5127..be85d50d15 100644
--- a/code_quality_tools/quality.gradle
+++ b/code_quality_tools/findbugs.gradle
@@ -10,11 +10,11 @@ task findbugs(type: FindBugs) {
html.enabled = true
xml.enabled = false
html {
- destination "${project.rootDir}/findbugs-report/findbugs-output.html"
+ destination "${project.rootDir}/reports/findbugs-output.html"
}
}
- classes = files("${project.projectDir}/build/intermediates/classes")
+ classes = files("${project.rootDir}/build/intermediates/classes")
source = fileTree('src/main/java')
// If somebody has an idea how to make this work with support libraries -> open a PR please.
diff --git a/reports/findbugs-output.html b/reports/findbugs-output.html
new file mode 100644
index 0000000000..a24de9e2b2
--- /dev/null
+++ b/reports/findbugs-output.html
@@ -0,0 +1,586 @@
+
+
+
+FindBugs Report
+
+
+
+
+
+Project Information
+Project:
+
+FindBugs version: 3.0.1
+Code analyzed:
+
+- /Users/kirillmakarov/work/makarovAndroid/stepik-android/app/build/intermediates/classes
+
+
+
+
+
+Metrics
+73205 lines of code analyzed,
+ in 2256 classes,
+ in 143 packages.
+
+
+
+High Priority Warnings |
+22 |
+0.30 |
+
+
+Medium Priority Warnings |
+ |
+0.00 |
+
+
+
+Total Warnings
+ |
+
+22
+ |
+
+0.30
+ |
+
+
+
+(* Defects per Thousand lines of non-commenting source statements)
+
+
+
+
+
+Contents
+
+Summary
+
+Warnings
+Click on a warning row to see full context information.
+
+
+
+
+
+MF
+ |
+Field SectionsFragment.localProgressManager masks field in superclass org.stepic.droid.base.FragmentBase |
+
+
+ |
+
+
+Bug type MF_CLASS_MASKS_FIELD (click for details)
+ In class org.stepic.droid.ui.fragments.SectionsFragment Masking field org.stepic.droid.ui.fragments.SectionsFragment.localProgressManager Masked field org.stepic.droid.base.FragmentBase.localProgressManager In SectionsFragment.java
+ |
+
+
+
+MF
+ |
+Field SectionsFragment.shareHelper masks field in superclass org.stepic.droid.base.FragmentBase |
+
+
+ |
+
+
+Bug type MF_CLASS_MASKS_FIELD (click for details)
+ In class org.stepic.droid.ui.fragments.SectionsFragment Masking field org.stepic.droid.ui.fragments.SectionsFragment.shareHelper Masked field org.stepic.droid.base.FragmentBase.shareHelper In SectionsFragment.java
+ |
+
+
+
+NP
+ |
+Null passed for non-null parameter of org.stepic.droid.util.StepikLogicHelper.getPathForCourseOrEmpty(Course, Config) in org.stepic.droid.ui.fragments.SectionsFragment.resolveJoinCourseView() |
+
+
+ |
+
+
+Bug type NP_NULL_PARAM_DEREF (click for details)
+ In class org.stepic.droid.ui.fragments.SectionsFragment In method org.stepic.droid.ui.fragments.SectionsFragment.resolveJoinCourseView() Called method org.stepic.droid.util.StepikLogicHelper.getPathForCourseOrEmpty(Course, Config) Argument 1 might be null but must not be null Value contained in org.stepic.droid.ui.fragments.SectionsFragment.course Method invoked at SectionsFragment.java:[line 357] Known null at SectionsFragment.java:[line 356]
+ |
+
+
+
+RCN
+ |
+Nullcheck of CancelLoadingService.databaseFacade at line 59 of value previously dereferenced in org.stepic.droid.services.CancelLoadingService.cancelStepVideo(long) |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE (click for details)
+ In class org.stepic.droid.services.CancelLoadingService In method org.stepic.droid.services.CancelLoadingService.cancelStepVideo(long) Value loaded from field org.stepic.droid.services.CancelLoadingService.databaseFacade At CancelLoadingService.kt:[line 54] Redundant null check at CancelLoadingService.kt:[line 59] Another occurrence at CancelLoadingService.kt:[line 60] Another occurrence at CancelLoadingService.kt:[line 61] Another occurrence at CancelLoadingService.kt:[line 66]
+ |
+
+
+
+RCN
+ |
+Nullcheck of DeleteService.databaseFacade at line 115 of value previously dereferenced in org.stepic.droid.services.DeleteService.removeFromDisk(long) |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE (click for details)
+ In class org.stepic.droid.services.DeleteService In method org.stepic.droid.services.DeleteService.removeFromDisk(long) Value loaded from field org.stepic.droid.services.DeleteService.databaseFacade At DeleteService.kt:[line 112] Redundant null check at DeleteService.kt:[line 115]
+ |
+
+
+
+RCN
+ |
+Nullcheck of DeleteService.databaseFacade at line 87 of value previously dereferenced in org.stepic.droid.services.DeleteService.removeFromDisk(Step) |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE (click for details)
+ In class org.stepic.droid.services.DeleteService In method org.stepic.droid.services.DeleteService.removeFromDisk(Step) Value loaded from field org.stepic.droid.services.DeleteService.databaseFacade At DeleteService.kt:[line 75] Redundant null check at DeleteService.kt:[line 87]
+ |
+
+
+
+RCN
+ |
+Nullcheck of UpdateWithApkService.userPrefs at line 46 of value previously dereferenced in org.stepic.droid.services.UpdateWithApkService.updateFromRemoteApk(String) |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE (click for details)
+ In class org.stepic.droid.services.UpdateWithApkService In method org.stepic.droid.services.UpdateWithApkService.updateFromRemoteApk(String) Value loaded from field org.stepic.droid.services.UpdateWithApkService.userPrefs At UpdateWithApkService.kt:[line 43] Redundant null check at UpdateWithApkService.kt:[line 46]
+ |
+
+
+
+RCN
+ |
+Nullcheck of CommentsFragment.commentManager at line 521 of value previously dereferenced in org.stepic.droid.ui.fragments.CommentsFragment.onCommentsLoaded() |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE (click for details)
+ In class org.stepic.droid.ui.fragments.CommentsFragment In method org.stepic.droid.ui.fragments.CommentsFragment.onCommentsLoaded() Value loaded from field org.stepic.droid.ui.fragments.CommentsFragment.commentManager At CommentsFragment.kt:[line 521] Redundant null check at CommentsFragment.kt:[line 521] Another occurrence at CommentsFragment.kt:[line 523]
+ |
+
+
+
+RCN
+ |
+Nullcheck of CommentsFragment.commentManager at line 497 of value previously dereferenced in org.stepic.droid.ui.fragments.CommentsFragment.onEmptyComments(DiscussionProxy) |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE (click for details)
+ In class org.stepic.droid.ui.fragments.CommentsFragment In method org.stepic.droid.ui.fragments.CommentsFragment.onEmptyComments(DiscussionProxy) Value loaded from field org.stepic.droid.ui.fragments.CommentsFragment.commentManager At CommentsFragment.kt:[line 496] Redundant null check at CommentsFragment.kt:[line 497]
+ |
+
+
+
+RCN
+ |
+Nullcheck of CommentsFragment.commentManager at line 307 of value previously dereferenced in org.stepic.droid.ui.fragments.CommentsFragment.openUserProfile(int) |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE (click for details)
+ In class org.stepic.droid.ui.fragments.CommentsFragment In method org.stepic.droid.ui.fragments.CommentsFragment.openUserProfile(int) Value loaded from field org.stepic.droid.ui.fragments.CommentsFragment.commentManager At CommentsFragment.kt:[line 305] Redundant null check at CommentsFragment.kt:[line 307]
+ |
+
+
+
+RCN
+ |
+Nullcheck of id at line 112 of value previously dereferenced in org.stepic.droid.util.HtmlHelperTest.predictCourseIdByHtml(long, String) |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE (click for details)
+ In class org.stepic.droid.util.HtmlHelperTest In method org.stepic.droid.util.HtmlHelperTest.predictCourseIdByHtml(long, String) Value loaded from id Return value of org.stepic.droid.util.HtmlHelper.parseCourseIdFromNotification(Notification) of type Long At HtmlHelperTest.kt:[line 112] Redundant null check at HtmlHelperTest.kt:[line 113]
+ |
+
+
+
+RCN
+ |
+Nullcheck of authenticationStepicResponse at line 178 of value previously dereferenced in org.stepic.droid.web.ApiImpl$1.intercept(Interceptor$Chain) |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE (click for details)
+ In class org.stepic.droid.web.ApiImpl$1 In method org.stepic.droid.web.ApiImpl$1.intercept(Interceptor$Chain) Value loaded from authenticationStepicResponse Return value of retrofit2.Call.execute() of type retrofit2.Response At ApiImpl.java:[line 178] Redundant null check at ApiImpl.java:[line 193]
+ |
+
+
+
+
+
+
+
+Dm
+ |
+Found reliance on default encoding in org.stepic.droid.configuration.ConfigImpl$ConfigFactory.create(): new java.io.InputStreamReader(InputStream) |
+
+
+ |
+
+
+Bug type DM_DEFAULT_ENCODING (click for details)
+ In class org.stepic.droid.configuration.ConfigImpl$ConfigFactory In method org.stepic.droid.configuration.ConfigImpl$ConfigFactory.create() Called method new java.io.InputStreamReader(InputStream) At ConfigImpl.kt:[line 24]
+ |
+
+
+
+Dm
+ |
+Found reliance on default encoding in org.stepic.droid.util.AndroidDevices.getStorageDirectories(): new java.io.FileReader(String) |
+
+
+ |
+
+
+Bug type DM_DEFAULT_ENCODING (click for details)
+ In class org.stepic.droid.util.AndroidDevices In method org.stepic.droid.util.AndroidDevices.getStorageDirectories() Called method new java.io.FileReader(String) At AndroidDevices.java:[line 114]
+ |
+
+
+
+
+
+
+
+MS
+ |
+org.stepic.droid.ui.fragments.SectionsFragment.joinFlag isn't final but should be |
+
+
+ |
+
+
+Bug type MS_SHOULD_BE_FINAL (click for details)
+ In class org.stepic.droid.ui.fragments.SectionsFragment Field org.stepic.droid.ui.fragments.SectionsFragment.joinFlag At SectionsFragment.java:[line 124]
+ |
+
+
+
+
+
+
+
+RCN
+ |
+Redundant nullcheck of org.stepic.droid.base.FragmentBase.unbinder, which is known to be non-null in org.stepic.droid.base.FragmentBase.onDestroyView() |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE (click for details)
+ In class org.stepic.droid.base.FragmentBase In method org.stepic.droid.base.FragmentBase.onDestroyView() Value loaded from field org.stepic.droid.base.FragmentBase.unbinder Redundant null check at FragmentBase.kt:[line 134]
+ |
+
+
+
+RCN
+ |
+Redundant nullcheck of org.stepic.droid.core.DefaultFilterImpl.isNeedRussian, which is known to be non-null in org.stepic.droid.core.DefaultFilterImpl.isNeedRussian() |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE (click for details)
+ In class org.stepic.droid.core.DefaultFilterImpl In method org.stepic.droid.core.DefaultFilterImpl.isNeedRussian() Value loaded from field org.stepic.droid.core.DefaultFilterImpl.isNeedRussian Redundant null check at DefaultFilterImpl.kt:[line 44]
+ |
+
+
+
+RCN
+ |
+Redundant nullcheck of org.stepic.droid.core.presenters.CertificatePresenter.certificateViewItemList, which is known to be non-null in org.stepic.droid.core.presenters.CertificatePresenter.showCertificates(boolean) |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE (click for details)
+ In class org.stepic.droid.core.presenters.CertificatePresenter In method org.stepic.droid.core.presenters.CertificatePresenter.showCertificates(boolean) Value loaded from field org.stepic.droid.core.presenters.CertificatePresenter.certificateViewItemList Redundant null check at CertificatePresenter.kt:[line 67] Another occurrence at CertificatePresenter.kt:[line 69]
+ |
+
+
+
+RCN
+ |
+Redundant nullcheck of org.stepic.droid.core.presenters.LessonPresenter.lesson, which is known to be non-null in org.stepic.droid.core.presenters.LessonPresenter.initUnitLessonWithIds(long, long) |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE (click for details)
+ In class org.stepic.droid.core.presenters.LessonPresenter In method org.stepic.droid.core.presenters.LessonPresenter.initUnitLessonWithIds(long, long) Value loaded from field org.stepic.droid.core.presenters.LessonPresenter.lesson Redundant null check at LessonPresenter.kt:[line 297]
+ |
+
+
+
+RCN
+ |
+Redundant nullcheck of nextUnitId, which is known to be non-null in org.stepic.droid.core.presenters.RouteStepPresenter$clickLessonBase$1.run() |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE (click for details)
+ In class org.stepic.droid.core.presenters.RouteStepPresenter$clickLessonBase$1 In method org.stepic.droid.core.presenters.RouteStepPresenter$clickLessonBase$1.run() Value loaded from nextUnitId Redundant null check at RouteStepPresenter.kt:[line 200]
+ |
+
+
+
+RCN
+ |
+Redundant nullcheck of org.stepic.droid.ui.dialogs.TimeIntervalPickerDialogFragment.picker, which is known to be non-null in org.stepic.droid.ui.dialogs.TimeIntervalPickerDialogFragment.onCreateDialog(Bundle) |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE (click for details)
+ In class org.stepic.droid.ui.dialogs.TimeIntervalPickerDialogFragment In method org.stepic.droid.ui.dialogs.TimeIntervalPickerDialogFragment.onCreateDialog(Bundle) Value loaded from field org.stepic.droid.ui.dialogs.TimeIntervalPickerDialogFragment.picker Redundant null check at TimeIntervalPickerDialogFragment.kt:[line 51] Another occurrence at TimeIntervalPickerDialogFragment.kt:[line 50] Another occurrence at TimeIntervalPickerDialogFragment.kt:[line 52] Another occurrence at TimeIntervalPickerDialogFragment.kt:[line 53] Another occurrence at TimeIntervalPickerDialogFragment.kt:[line 54] Another occurrence at TimeIntervalPickerDialogFragment.kt:[line 55] Another occurrence at TimeIntervalPickerDialogFragment.kt:[line 57]
+ |
+
+
+
+RCN
+ |
+Redundant nullcheck of org.stepic.droid.ui.fragments.VideoExoFragment.player, which is known to be non-null in org.stepic.droid.ui.fragments.VideoExoFragment.onInternetEnabled() |
+
+
+ |
+
+
+Bug type RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE (click for details)
+ In class org.stepic.droid.ui.fragments.VideoExoFragment In method org.stepic.droid.ui.fragments.VideoExoFragment.onInternetEnabled() Value loaded from field org.stepic.droid.ui.fragments.VideoExoFragment.player Redundant null check at VideoExoFragment.kt:[line 407]
+ |
+
+
+
+
+
+ Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.
+
+
+
+
+ This class defines a field with the same name as a visible
+instance field in a superclass. This is confusing, and
+may indicate an error if methods update or access one of
+the fields when they wanted the other.
+
+
+
+
+
+This static field public but not final, and
+could be changed by malicious code or
+ by accident from another package.
+ The field could be made final to avoid
+ this vulnerability.
+
+
+
+
+
+ This method call passes a null value for a non-null method parameter.
+ Either the parameter is annotated as a parameter that should
+ always be non-null, or analysis has shown that it will always be
+ dereferenced.
+
+
+
+
+
+ A value is checked here to see whether it is null, but this value can't
+be null because it was previously dereferenced and if it were null a null pointer
+exception would have occurred at the earlier dereference.
+Essentially, this code and the previous dereference
+disagree as to whether this value is allowed to be null. Either the check is redundant
+or the previous dereference is erroneous.
+
+
+
+
+ This method contains a redundant check of a known non-null value against
+the constant null.
+
+
+