Talentica/AndroidWithKotlin

View on GitHub

Showing 83 of 83 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    private fun configPreviewRatioAndSize(params: Camera.Parameters, ratio: Ratio) {
        val selected = ratio.extractFourByThreeSize(camera.parameters?.supportedPreviewSizes!!)
        params.setPreviewSize(selected.width, selected.height)
    }
customcamera/src/main/java/com/talentica/androidkotlin/customcamera/model/camera/CameraAdapter.kt on lines 177..180

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 108.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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)

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      package com.talentica.androidkotlin.networking
      
      import androidx.test.platform.app.InstrumentationRegistry
      import androidx.test.runner.AndroidJUnit4
      import org.junit.Assert.assertEquals
      sensors/src/androidTest/java/com/talentica/androidkotlin/sensors/ExampleInstrumentedTest.kt on lines 1..23

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 99.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      package com.talentica.androidkotlin.sensors
      
      import androidx.test.platform.app.InstrumentationRegistry
      import androidx.test.runner.AndroidJUnit4
      import org.junit.Assert.assertEquals
      networking/src/androidTest/java/com/talentica/androidkotlin/networking/ExampleInstrumentedTest.kt on lines 1..23

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 99.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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 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;

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              private fun createOk(key: String? = null, value: String? = null) : com.google.gson.JsonObject {
                  return create("ok", key, value)
              }
          sqlitedatabase/src/main/java/com/talentica/androidkotlin/sqlitedatabase/server/MockUserService.kt on lines 14..16

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 97.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              private fun requestCameraPermission() {
                  // Here, thisActivity is the current activity
                  // Should we show an explanation?
                  if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.CAMERA)) {
                      // Show an explanation to the user *asynchronously* -- don't block
          customcamera/src/main/java/com/talentica/androidkotlin/customcamera/presenter/landing/LandingActivityPresenterImpl.kt on lines 58..72

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 97.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      if (ContextCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                          //File write logic here
                          if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
                              // Show an explanation to the user *asynchronously* -- don't block
                              // this thread waiting for the user's response! After the user
          customcamera/src/main/java/com/talentica/androidkotlin/customcamera/presenter/camera/CameraActivityPresenterImpl.kt on lines 41..56

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 97.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              private fun createError(key: String? = null, value: String? = null) : com.google.gson.JsonObject {
                  return create("error", key, value)
              }
          sqlitedatabase/src/main/java/com/talentica/androidkotlin/sqlitedatabase/server/MockUserService.kt on lines 10..12

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 97.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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) {

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    override fun showLoading() {
                        val handler = Handler(Looper.getMainLooper())
                        handler.post({
                            progressBar.visibility = View.VISIBLE
                            repoList.alpha = 0.4f
                networking/src/main/java/com/talentica/androidkotlin/networking/repoui/UserRepositories.kt on lines 66..72

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 92.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    override fun hideLoading() {
                        val handler = Handler(Looper.getMainLooper())
                        handler.post({
                            progressBar.visibility = View.GONE
                            repoList.alpha = 1.0f
                networking/src/main/java/com/talentica/androidkotlin/networking/repoui/UserRepositories.kt on lines 58..64

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 92.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                            override fun onFailure(call: Call<Array<Repository>>?, t: Throwable?) {
                
                                if (!isAlive) {
                                    return
                                }
                networking/src/main/java/com/talentica/androidkotlin/networking/repoui/RepoPresenter.kt on lines 114..123

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 85.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                            override fun onFailure(call: okhttp3.Call, e: IOException) {
                
                                if (!isAlive) {
                                    return
                                }
                networking/src/main/java/com/talentica/androidkotlin/networking/repoui/RepoPresenter.kt on lines 66..75

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 85.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    fun v(tag: String, vararg messages: Any) {
                        // Only log VERBOSE if build type is DEBUG
                        if (BuildConfig.DEBUG) {
                            log(tag, Log.VERBOSE, null, *messages)
                        }
                audioplayer/src/main/java/com/talentica/androidkotlin/audioplayer/utils/LogHelper.kt on lines 36..41

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 85.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    fun d(tag: String, vararg messages: Any) {
                        // Only log DEBUG if build type is DEBUG
                        if (BuildConfig.DEBUG) {
                            log(tag, Log.DEBUG, null, *messages)
                        }
                audioplayer/src/main/java/com/talentica/androidkotlin/audioplayer/utils/LogHelper.kt on lines 29..34

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 85.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Severity
                Category
                Status
                Source
                Language