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: [FC-0072] Static code analyzer #403

Merged
merged 5 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
33 changes: 33 additions & 0 deletions .github/workflows/detekt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Detekt

on:
workflow_dispatch:
pull_request: { }

env:
GRADLE_OPTS: -Dorg.gradle.daemon=false
CI_GRADLE_ARG_PROPERTIES: --stacktrace

jobs:
linting:
name: Run Detekt
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'

- name: Run Detekt
run: ./gradlew detektAll

- name: Upload report
uses: github/codeql-action/upload-sarif@v3
if: success() || failure()
with:
sarif_file: build/reports/detekt/detekt.sarif
229 changes: 153 additions & 76 deletions app/src/main/java/org/openedx/app/AnalyticsManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ import org.openedx.foundation.interfaces.Analytics
import org.openedx.profile.presentation.ProfileAnalytics
import org.openedx.whatsnew.presentation.WhatsNewAnalytics

class AnalyticsManager : AppAnalytics, AppReviewAnalytics, AuthAnalytics, CoreAnalytics,
CourseAnalytics, DashboardAnalytics, DiscoveryAnalytics, DiscussionAnalytics,
ProfileAnalytics, WhatsNewAnalytics {
class AnalyticsManager :
AppAnalytics,
AppReviewAnalytics,
AuthAnalytics,
CoreAnalytics,
CourseAnalytics,
DashboardAnalytics,
DiscoveryAnalytics,
DiscussionAnalytics,
ProfileAnalytics,
WhatsNewAnalytics {

private val analytics: MutableList<Analytics> = mutableListOf()

Expand Down Expand Up @@ -45,17 +53,26 @@ class AnalyticsManager : AppAnalytics, AppReviewAnalytics, AuthAnalytics, CoreAn
}
}

override fun dashboardCourseClickedEvent(courseId: String, courseName: String) {
logEvent(Event.DASHBOARD_COURSE_CLICKED, buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
})
override fun dashboardCourseClickedEvent(
courseId: String,
courseName: String
) {
logEvent(
Event.DASHBOARD_COURSE_CLICKED,
buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
}
)
}

override fun logoutEvent(force: Boolean) {
logEvent(Event.USER_LOGOUT, buildMap {
put(Key.FORCE.keyName, force)
})
logEvent(
Event.USER_LOGOUT,
buildMap {
put(Key.FORCE.keyName, force)
}
)
}

override fun setUserIdForSession(userId: Long) {
Expand All @@ -67,104 +84,164 @@ class AnalyticsManager : AppAnalytics, AppReviewAnalytics, AuthAnalytics, CoreAn
}

override fun discoveryCourseSearchEvent(label: String, coursesCount: Int) {
logEvent(Event.DISCOVERY_COURSE_SEARCH, buildMap {
put(Key.LABEL.keyName, label)
put(Key.COURSE_COUNT.keyName, coursesCount)
})
logEvent(
Event.DISCOVERY_COURSE_SEARCH,
buildMap {
put(Key.LABEL.keyName, label)
put(Key.COURSE_COUNT.keyName, coursesCount)
}
)
}

override fun discoveryCourseClickedEvent(courseId: String, courseName: String) {
logEvent(Event.DISCOVERY_COURSE_CLICKED, buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
})
logEvent(
Event.DISCOVERY_COURSE_CLICKED,
buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
}
)
}

override fun sequentialClickedEvent(
courseId: String, courseName: String, blockId: String, blockName: String,
courseId: String,
courseName: String,
blockId: String,
blockName: String,
) {
logEvent(Event.SEQUENTIAL_CLICKED, buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
put(Key.BLOCK_ID.keyName, blockId)
put(Key.BLOCK_NAME.keyName, blockName)
})
logEvent(
Event.SEQUENTIAL_CLICKED,
buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
put(Key.BLOCK_ID.keyName, blockId)
put(Key.BLOCK_NAME.keyName, blockName)
}
)
}

override fun nextBlockClickedEvent(
courseId: String, courseName: String, blockId: String, blockName: String,
courseId: String,
courseName: String,
blockId: String,
blockName: String,
) {
logEvent(Event.NEXT_BLOCK_CLICKED, buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
put(Key.BLOCK_ID.keyName, blockId)
put(Key.BLOCK_NAME.keyName, blockName)
})
logEvent(
Event.NEXT_BLOCK_CLICKED,
buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
put(Key.BLOCK_ID.keyName, blockId)
put(Key.BLOCK_NAME.keyName, blockName)
}
)
}

override fun prevBlockClickedEvent(
courseId: String, courseName: String, blockId: String, blockName: String,
courseId: String,
courseName: String,
blockId: String,
blockName: String,
) {
logEvent(Event.PREV_BLOCK_CLICKED, buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
put(Key.BLOCK_ID.keyName, blockId)
put(Key.BLOCK_NAME.keyName, blockName)
})
logEvent(
Event.PREV_BLOCK_CLICKED,
buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
put(Key.BLOCK_ID.keyName, blockId)
put(Key.BLOCK_NAME.keyName, blockName)
}
)
}

override fun finishVerticalClickedEvent(
courseId: String, courseName: String, blockId: String, blockName: String,
courseId: String,
courseName: String,
blockId: String,
blockName: String,
) {
logEvent(Event.FINISH_VERTICAL_CLICKED, buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
put(Key.BLOCK_ID.keyName, blockId)
put(Key.BLOCK_NAME.keyName, blockName)
})
logEvent(
Event.FINISH_VERTICAL_CLICKED,
buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
put(Key.BLOCK_ID.keyName, blockId)
put(Key.BLOCK_NAME.keyName, blockName)
}
)
}

override fun finishVerticalNextClickedEvent(
courseId: String, courseName: String, blockId: String, blockName: String,
courseId: String,
courseName: String,
blockId: String,
blockName: String,
) {
logEvent(Event.FINISH_VERTICAL_NEXT_CLICKED, buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
put(Key.BLOCK_ID.keyName, blockId)
put(Key.BLOCK_NAME.keyName, blockName)
})
logEvent(
Event.FINISH_VERTICAL_NEXT_CLICKED,
buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
put(Key.BLOCK_ID.keyName, blockId)
put(Key.BLOCK_NAME.keyName, blockName)
}
)
}

override fun finishVerticalBackClickedEvent(courseId: String, courseName: String) {
logEvent(Event.FINISH_VERTICAL_BACK_CLICKED, buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
})
override fun finishVerticalBackClickedEvent(
courseId: String,
courseName: String
) {
logEvent(
Event.FINISH_VERTICAL_BACK_CLICKED,
buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
}
)
}

override fun discussionAllPostsClickedEvent(courseId: String, courseName: String) {
logEvent(Event.DISCUSSION_ALL_POSTS_CLICKED, buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
})
override fun discussionAllPostsClickedEvent(
courseId: String,
courseName: String
) {
logEvent(
Event.DISCUSSION_ALL_POSTS_CLICKED,
buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
}
)
}

override fun discussionFollowingClickedEvent(courseId: String, courseName: String) {
logEvent(Event.DISCUSSION_FOLLOWING_CLICKED, buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
})
override fun discussionFollowingClickedEvent(
courseId: String,
courseName: String
) {
logEvent(
Event.DISCUSSION_FOLLOWING_CLICKED,
buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
}
)
}

override fun discussionTopicClickedEvent(
courseId: String, courseName: String, topicId: String, topicName: String,
courseId: String,
courseName: String,
topicId: String,
topicName: String,
) {
logEvent(Event.DISCUSSION_TOPIC_CLICKED, buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
put(Key.TOPIC_ID.keyName, topicId)
put(Key.TOPIC_NAME.keyName, topicName)
})
logEvent(
Event.DISCUSSION_TOPIC_CLICKED,
buildMap {
put(Key.COURSE_ID.keyName, courseId)
put(Key.COURSE_NAME.keyName, courseName)
put(Key.TOPIC_ID.keyName, topicId)
put(Key.TOPIC_NAME.keyName, topicName)
}
)
}
}

Expand Down
Loading
Loading