All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wartremover.warts.SizeToLength.scala Maven / Gradle / Ivy

There is a newer version: 3.2.4
Show newest version
package org.wartremover
package warts

import scala.quoted.Expr
import scala.quoted.quotes

object SizeToLength
    extends ExprMatch({
      val message = "Maybe you should use `length` instead of `size`"
      import quotes.reflect.*
      val f: PartialFunction[Expr[Any], String] = {
        case '{ Predef.genericArrayOps[t]($x1).size } =>
          message
        case '{ Predef.booleanArrayOps($x1).size } =>
          message
        case '{ Predef.byteArrayOps($x1).size } =>
          message
        case '{ Predef.charArrayOps($x1).size } =>
          message
        case '{ Predef.doubleArrayOps($x1).size } =>
          message
        case '{ Predef.floatArrayOps($x1).size } =>
          message
        case '{ Predef.intArrayOps($x1).size } =>
          message
        case '{ Predef.longArrayOps($x1).size } =>
          message
        case '{
              type t <: AnyRef
              Predef.refArrayOps[`t`]($x1).size
            } =>
          message
        case '{ Predef.shortArrayOps($x1).size } =>
          message
        case '{ Predef.unitArrayOps($x1).size } =>
          message
        case '{ Predef.augmentString($x1).size } =>
          message
      }
      f
    })




© 2015 - 2024 Weber Informatics LLC | Privacy Policy