Showing 246 of 862 total issues
Method initializeUI
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private fun initializeUI() {
replaceFragmentSafely(
fragment = AdminOverviewFragment(),
containerViewId = R.id.pagerAdmin,
allowStateLoss = true
Method onClick
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
override fun onClick(v: View) {
when (v.id) {
R.id.notesBtn -> {
vm.type = getString(R.string.notes)
replaceFragmentSafely(
Method insertSections
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
suspend fun insertSections(runAttempt: RunAttempts, refresh: Boolean = false) {
val runAttemptModel = RunAttemptModel(
runAttempt.id,
runAttempt.certificateApproved,
runAttempt.end,
Method initializeDownload
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private fun initializeDownload(mOtp: String, mPlaybackInfo: String, videoId: String) {
val optionsDownloader = OptionsDownloader()
optionsDownloader.downloadOptionsWithOtp(
mOtp, mPlaybackInfo,
object : OptionsDownloader.Callback {
Method onViewCreated
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
sheetBehavior = BottomSheetBehavior.from(bottom_sheet)
nextBtn.setOnClickListener(this)
Method createDoubt
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
fun createDoubt(title: String, body: String, function: (message: String) -> Unit) {
val doubt = Doubts(
null, title, body, RunAttempts(attemptId.value ?: ""),
LectureContent(
currentContentId
Method setupViewPager
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private fun setupViewPager() {
pagerAdapter.apply {
add(ViewPager2Adapter.FragmentName.COURSE_OVERVIEW)
add(ViewPager2Adapter.FragmentName.COURSE_CURRICULUM)
Method setUpObservers
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private fun setUpObservers() {
viewModel.getJobById(jobId).observeOnce {
with(it) {
companyLogo.loadImage(company.logo)
jobTitleTv.text = title
Method logout
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
fun logout(view: View) {
showDialog(
type = "Logout",
image = R.drawable.ic_info,
cancelable = false,
Method showRatingDialog
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private fun showRatingDialog() {
val dialog = AlertDialog.Builder(requireContext()).create()
val ratingDialog = requireContext().layoutInflater.inflate(R.layout.rating_dialog, null)
vm.getFeedback().observer(viewLifecycleOwner) {
dialog.overallExp.setText(it?.userScore?.heading)
Method showDialog
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private fun showDialog() {
val dialog = AlertDialog.Builder(this).create()
val view = layoutInflater.inflate(R.layout.dialog_share, null)
val msg = "Signup using this link to get 500 credits in your wallet and stand a chance of winning amazing prizes this Summer using my referral code: https://cb.lk/join/${vm.referral
?: ""}"
Method doWork
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
override suspend fun doWork(): Result {
val contentDao: ContentDao by inject()
val contentId = workerParameters.inputData.getString(CONTENT_ID)
val attemptId = workerParameters.inputData.getString(RUN_ATTEMPT_ID)
var progressId: String? = withContext(Dispatchers.IO) { contentDao.getProgressId(contentId ?: "") }
Method getDistinct
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
fun <T> LiveData<T>.getDistinct(): LiveData<T> {
val distinctLiveData = MediatorLiveData<T>()
distinctLiveData.addSource(
this,
object : Observer<T> {
Method openDownloadedFile
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private fun openDownloadedFile(
context: Context,
downloadId: Long
) {
val downloadManager =
Method insertJobs
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
suspend fun insertJobs(jobs: List<Jobs>) {
jobs.forEach { job ->
with(job) {
val company = withContext(Dispatchers.IO) {
CBOnlineLib.onlineV2JsonApi.getCompany(company?.id ?: "")
Method onViewCreated
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
Open
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel.fetchSections()
typeChipGroup.setOnCheckedChangeListener { _, checkedId ->
when (checkedId) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method onCreate
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
Open
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_code_challenge)
setToolbar(toolbarCodeChallenge, title = "")
if (savedInstanceState == null) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method setSecondSpan
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private fun setSecondSpan() {
val policySpan = SpannableString(
"By logging in you agree to Coding Blocks’s\n" +
"Privacy Policy & Terms of Service"
)
Method onCreate
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_learning_tracks)
setToolbar(tracksToolbar)
setUpBottomSheet()
Method changeToolbar
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private fun changeToolbar(title: String, pos: Int) {
dashboardPager.setCurrentItem(pos, true)
supportActionBar?.title = title
if (pos == 0 || pos == 2)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {