Talentica/AndroidWithKotlin

View on GitHub

Showing 21 of 83 total issues

Method setCommentList has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
Open

    fun setCommentList(comments: List<CommentEntity?>?) {
        if (mCommentList == null) {
            mCommentList = comments
            if (comments != null) {
                notifyItemRangeInserted(0, comments.size)
Severity: Minor
Found in app/src/main/java/com/talentica/androidkotlin/ui/CommentAdapter.kt - About 3 hrs to fix

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

    fun setProductList(productList: List<ProductEntity?>?) {
        if (mProductList == null) {
            mProductList = productList
            if (productList != null) {
                notifyItemRangeInserted(0, productList.size)
Severity: Minor
Found in app/src/main/java/com/talentica/androidkotlin/ui/ProductAdapter.kt - About 3 hrs to fix

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

Class CameraAdapter has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class CameraAdapter constructor() : Camera.PictureCallback {

    companion object {
        private val ROTATION_DEGREE = 90
        private val MIN_AUTO_FOCUS_COUNT = 1

    Method addUserObservers has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private fun addUserObservers() {
            // Manage the response from the server to "Search", turn the JsonObject into a User,
            // if the response is "ok"
            mUserObservable
                    .observeOn(AndroidSchedulers.mainThread())

      Method setProductList has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          fun setProductList(productList: List<ProductEntity?>?) {
              if (mProductList == null) {
                  mProductList = productList
                  if (productList != null) {
                      notifyItemRangeInserted(0, productList.size)
      Severity: Minor
      Found in app/src/main/java/com/talentica/androidkotlin/ui/ProductAdapter.kt - About 1 hr to fix

        Method setCommentList has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            fun setCommentList(comments: List<CommentEntity?>?) {
                if (mCommentList == null) {
                    mCommentList = comments
                    if (comments != null) {
                        notifyItemRangeInserted(0, comments.size)
        Severity: Minor
        Found in app/src/main/java/com/talentica/androidkotlin/ui/CommentAdapter.kt - About 1 hr to fix

          Method addSearchFieldObservers has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private fun addSearchFieldObservers() {
                  // Whenever a new character is typed
                  WidgetObservable.text(editText)
                          .doOnNext { e: OnTextChangeEvent ->
                              addFriendButton?.setEnabled(false)

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

                /**
                 * Creates or returns a previously-created database.
                 *
                 *
                 * Although this uses an AsyncTask which currently uses a serial executor, it's thread-safe.
            Severity: Minor
            Found in app/src/main/java/com/talentica/androidkotlin/db/DatabaseCreator.kt - About 1 hr to fix

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

                  private fun loadWithRetrofit(username: String) {
                      val retrofit = Retrofit.Builder().baseUrl("https://api.github.com/")
                              .addConverterFactory(GsonConverterFactory.create()).build()
              
                      val retrofitService = retrofit.create(RetrofitService::class.java)

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

                    public static String getTestData(Context context) {
                
                        StringBuilder returnString = new StringBuilder();
                        InputStream fIn = null;
                        InputStreamReader isr = null;

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

                      private fun generateData(
                          products: MutableList<ProductEntity>,
                          comments: MutableList<CommentEntity>
                      ) {
                          val rnd = Random()

                    Method loadWithOkHttp has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private fun loadWithOkHttp(username: String) {
                            OkHttpService.httpGet(username, object : okhttp3.Callback {
                                override fun onFailure(call: okhttp3.Call, e: IOException) {
                    
                                    if (!isAlive) {

                      Method onResult has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          //If using emulator then send the location from Emulator's Extended Controls. :)
                          override fun onResult(locationSettingsResult: LocationSettingsResult) {
                              val status: Status = locationSettingsResult.getStatus();
                              when (status.getStatusCode()) {
                                  LocationSettingsStatusCodes.SUCCESS -> {

                        Method onSensorChanged has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            override fun onSensorChanged(event: SensorEvent) {
                                val alpha = 0.97f
                        
                                synchronized(this) {
                                    if (event.sensor.type == Sensor.TYPE_ACCELEROMETER) {

                          Method createChannel has 7 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              fun createChannel(id: String?, name: CharSequence?, importance: Int,
                                                showBadge: Boolean, group: String, color: Int, vibrationPattern: LongArray) {

                            Method createChannel has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    fun createChannel(id: String, name: CharSequence, importance: Int, showBadge: Boolean,
                                                      group: String = "Personal", vibrationPattern: LongArray = longArrayOf
                                    (100, 200, 300, 100, 200, 300, 100, 200, 300))

                              Method createChannel has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  override fun createChannel(id: String, name: CharSequence, importance: Int, showBadge:
                                  Boolean, group: String, vibrationPattern: LongArray) {

                                Method createNotification has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    fun createNotification(channelId: String, title: String, body: String, ticker: String, onGoing:
                                    Boolean, color: Int): Int {

                                  Method createNotification has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      override fun createNotification(channel: String, title: String, body: String, onGoing:
                                      Boolean, color: Int) {

                                    Method createNotification has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                            fun createNotification(channel: String, title: String, body: String, onGoing: Boolean,
                                                                   color: Int = Color.GREEN)
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language