Talentica/AndroidWithKotlin

View on GitHub

Showing 83 of 83 total issues

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

if (event.sensor.type == Sensor.TYPE_MAGNETIC_FIELD) {
// mGeomagnetic = event.values;
mGeomagnetic[0] = alpha * mGeomagnetic[0] + (1 - alpha) * event.values[0]
mGeomagnetic[1] = alpha * mGeomagnetic[1] + (1 - alpha) * event.values[1]
mGeomagnetic[2] = alpha * mGeomagnetic[2] + (1 - alpha) * event.values[2]
sensors/src/main/java/com/talentica/androidkotlin/sensors/Compass.kt on lines 48..54

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

if (event.sensor.type == Sensor.TYPE_ACCELEROMETER) {
mGravity[0] = alpha * mGravity[0] + (1 - alpha) * event.values[0]
mGravity[1] = alpha * mGravity[1] + (1 - alpha) * event.values[1]
mGravity[2] = alpha * mGravity[2] + (1 - alpha) * event.values[2]
// mGravity = event.values;
sensors/src/main/java/com/talentica/androidkotlin/sensors/Compass.kt on lines 56..62

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

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

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

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate this data binding layout
app/src/main/java/com/talentica/androidkotlin/ProductListFragment.kt on lines 35..43

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

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
mBinding = DataBindingUtil.inflate(inflater, R.layout.list_fragment, container, false)
app/src/main/java/com/talentica/androidkotlin/ProductFragment.kt on lines 34..45

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

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

    override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
    val old = mCommentList!![oldItemPosition]
    val comment = comments?.get(newItemPosition)
    return if (old != null && comment != null) {
    old.id == comment.id
    app/src/main/java/com/talentica/androidkotlin/ui/ProductAdapter.kt on lines 47..55

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

    override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
    val old = mProductList!![oldItemPosition]
    val new = productList?.get(newItemPosition)
    return if (old != null && new != null) {
    old.id == new.id
    app/src/main/java/com/talentica/androidkotlin/ui/CommentAdapter.kt on lines 47..55

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

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CommentViewHolder {
    val binding: CommentItemBinding = DataBindingUtil
    .inflate(
    LayoutInflater.from(parent.context), R.layout.comment_item,
    parent, false
    app/src/main/java/com/talentica/androidkotlin/ui/ProductAdapter.kt on lines 77..85

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

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProductViewHolder {
    val binding: ProductItemBinding = DataBindingUtil
    .inflate(
    LayoutInflater.from(parent.context), R.layout.product_item,
    parent, false
    app/src/main/java/com/talentica/androidkotlin/ui/CommentAdapter.kt on lines 75..83

    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

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

          observableProduct = databaseCreator?.let {
          Transformations.switchMap(
          it.isDatabaseCreated
          ) { isDbCreated ->
          if (!isDbCreated!!) {
          app/src/main/java/com/talentica/androidkotlin/viewmodel/ProductViewModel.kt on lines 72..82

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

          comments = databaseCreator?.let {
          Transformations.switchMap(
          it.isDatabaseCreated
          ) { isDbCreated ->
          if (!isDbCreated!!) {
          app/src/main/java/com/talentica/androidkotlin/viewmodel/ProductViewModel.kt on lines 83..93

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

          model.comments?.observe(viewLifecycleOwner, { commentEntities ->
          if (commentEntities != null) {
          mBinding.isLoading = false
          mCommentAdapter!!.setCommentList(commentEntities)
          } else {
          app/src/main/java/com/talentica/androidkotlin/ProductListFragment.kt on lines 55..62

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

          viewModel.products?.observe(viewLifecycleOwner, { myProducts ->
          if (myProducts != null) {
          mBinding.isLoading = false
          mProductAdapter!!.setProductList(myProducts)
          } else {
          app/src/main/java/com/talentica/androidkotlin/ProductFragment.kt on lines 72..79

          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)

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

            private fun configPictureRatioAndSize(params: Camera.Parameters, ratio: Ratio) {
            val selected = ratio.extractFourByThreeSize(camera.parameters?.supportedPictureSizes!!)
            params.setPictureSize(selected.width, selected.height)
            }
            customcamera/src/main/java/com/talentica/androidkotlin/customcamera/model/camera/CameraAdapter.kt on lines 172..175
            Severity
            Category
            Status
            Source
            Language