coding-blocks/CBOnlineApp

View on GitHub

Showing 246 of 862 total issues

Method changeToolbar has 31 lines of code (exceeds 25 allowed). Consider refactoring.
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) {

    Method onStartCommand has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
            if (intent.action == ACTION_STOP) {
                stopServiceManually()
                notificationManager.cancel(NOTIFICATION_ID)
            } else {

      Method initializeDownload has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private fun initializeDownload(mOtp: String, mPlaybackInfo: String, videoId: String) {
              val optionsDownloader = OptionsDownloader()
              // assuming we have otp and playbackInfo
              optionsDownloader.downloadOptionsWithOtp(
                  mOtp,

        Method onViewCreated has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
                super.onViewCreated(view, savedInstanceState)
                CookieManager.getInstance().apply {
                    removeAllCookies {
                    }

          Method onCreate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              override fun onCreate(savedInstanceState: Bundle?) {
                  super.onCreate(savedInstanceState)
                  setContentView(R.layout.activity_checkout)
                  setToolbar(checkoutToolbar)
                  Checkout.preload(applicationContext)

            Method onViewCreated has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
                    super.onViewCreated(view, savedInstanceState)
            
                    emailBtn.setOnClickListener {
                        val email = emailEdtv.text.toString()

              Method getView has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
                      val view = convertView
                          ?: LayoutInflater.from(parent.context).inflate(R.layout.item_run_comparision, parent, false)
              
                      val sheetItem = getItem(position)

                Method onReceive has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    override fun onReceive(context: Context, intent: Intent) {
                        val alarmMgr = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
                
                        val i = Intent(context, DoubtReceiver::class.java)
                
                

                  Method loadImage has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  fun ImageView.loadImage(imgUrl: String, scale: Boolean = false, callback: (loaded: Boolean) -> Unit = { }) {
                      if (imgUrl.isNotEmpty()) {
                          createGlideRequest(Uri.parse(imgUrl), context)
                              .listener(SvgSoftwareLayerSetter())
                              .listener(object : RequestListener<Drawable> {

                    Method digitalClockTime has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        fun digitalClockTime(timeInMilliSeconds: Int): String {
                            val totalSeconds = timeInMilliSeconds / 1000
                            val hours = totalSeconds / (60 * 60)
                            val minutes = (totalSeconds - hours * 60 * 60) / 60
                            val seconds = totalSeconds - hours * 60 * 60 - minutes * 60
                    Severity: Minor
                    Found in app/src/main/java/com/codingblocks/cbonlineapp/util/VideoUtils.kt - About 1 hr to fix

                      Method notificationReceived has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          override fun notificationReceived(notification: OSNotification) {
                      
                              try {
                                  val data = notification.payload.additionalData
                                  val title = notification.payload.title

                        Method initializeUI has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private fun initializeUI(loggedIn: Boolean) {
                                searchBtn.setOnClickListener {
                                    startActivity(intentFor<LearningTracksActivity>().singleTop())
                                }
                                pagerAdapter.apply {

                          Method replaceFragmentSafely has 9 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              fragment: Fragment,
                              tag: String = "",
                              allowStateLoss: Boolean = false,
                              @IdRes containerViewId: Int,
                              @AnimRes enterAnimation: Int = 0,

                            Method replaceFragmentSafely has 9 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                fragment: Fragment,
                                tag: String = "",
                                allowStateLoss: Boolean = false,
                                @IdRes containerViewId: Int,
                                @AnimatorRes enterAnimation: Int = R.animator.slide_in_left,

                              Method onCreate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  override fun onCreate(savedInstanceState: Bundle?) {
                                      super.onCreate(savedInstanceState)
                                      setContentView(R.layout.activity_referral)
                                      setToolbar(referralToolbar)
                              
                              

                                Method timeAgo has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                fun timeAgo(time: Long): String {
                                    val diff = floor(((System.currentTimeMillis() - time) / 1000).toDouble())
                                    var interval = floor(diff / 31536000).toInt()
                                    if (interval >= 1) {
                                        return "$interval Years Ago"

                                  Method fetchQuiz has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      fun fetchQuiz() {
                                          runIO {
                                              when (val response = quiz.qnaQid.let { repo.getQuizDetails(quizId = it.toString()) }) {
                                                  is ResultWrapper.GenericError -> setError(response.error)
                                                  is ResultWrapper.Success -> {

                                    Method logout has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                                    Open

                                        fun logout(view: View) {
                                            showDialog(
                                                type = "Logout",
                                                image = R.drawable.ic_info,
                                                cancelable = false,

                                    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 fetchCurrentTrack has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                                    Open

                                        fun fetchCurrentTrack() {
                                            runIO {
                                                when (val response = repo.getTrack(id)) {
                                                    is ResultWrapper.GenericError -> setError(response.error)
                                                    is ResultWrapper.Success -> with(response.value) {

                                    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 onViewCreated has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                                    Open

                                        override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
                                            super.onViewCreated(view, savedInstanceState)
                                    
                                            vm.fetchRecommendedCourses(0, 4)
                                            vm.fetchRecommendedCourses(4, 4)

                                    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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language