mapbox-maps-android icon indicating copy to clipboard operation
mapbox-maps-android copied to clipboard

Most expression now show lint error "Incorrect number of expressions"

Open SamYStudiO opened this issue 1 year ago • 12 comments

Since mapbox Android 11.4.0

For example

circleColor(
    switchCase {
        eq {
            get { literal("type") }
            literal(RouteShapeWaypointType.AUTO.name)
        }
        color(Color.RED)

        color(Color.YELLOW)
    },
)

Here both switchCase and eq expression are concerned !!!

image

Incorrect number of expressions within switchCase Expression: expected an odd number, but 2 was found. More... (Ctrl+F1)

Incorrect number of expressions within eq Expression: expected 2 or 3, but 1 was found. More... (Ctrl+F1)

SamYStudiO avatar May 13 '24 15:05 SamYStudiO

@SamYStudiO hey!

Since mapbox Android 11.4.0

What version did you use before moving to 11.4.0?

kiryldz avatar May 13 '24 17:05 kiryldz

@SamYStudiO hey!

Since mapbox Android 11.4.0

What version did you use before moving to 11.4.0?

@kiryldz 11.3

SamYStudiO avatar May 13 '24 17:05 SamYStudiO

@SamYStudiO I do not see similar issues and we did not modify those lint rules between v11.3 and v11.4. I assume that despite lint complaining - the code does compile OK, right?

kiryldz avatar May 14 '24 07:05 kiryldz

@kiryldz It does compile ! I was coming from 11.3 but since i haven't tried to compile with 11.3 i may have missed the issue and so it may be anterior to 11.3

SamYStudiO avatar May 14 '24 12:05 SamYStudiO

Maybe related to gradle update. At least I started getting these after updating to AGP 8.4.0.

ittna avatar May 16 '24 12:05 ittna

I also started experiencing this after updating AGP to 8.4.1

jsoberg avatar May 31 '24 23:05 jsoberg

Same here.

If the expression is not too complex, you can change the way it is set:

from iconRotate(get { literal("heading") }) to iconRotate(Expression.get("heading"))

NasH5169 avatar Jun 04 '24 09:06 NasH5169

I had the same issue using gradle 8.2.0. Rolling back to 8.0 "solved" it for me. I spent 2 days smacking my head off that particular wall.

Incidentally, I think the documentation, examples and general developer experience of using the expression dsl in Compose is quite poor compared to most of the library. Its a shame considering the careful thought and effort that obviously went into the implementation.

No doubt it will be improved as maps-compose matures into the standard choice for green-field work.

brianpowerkws avatar Jun 18 '24 15:06 brianpowerkws

Any update?

kdaccenture avatar Aug 06 '24 09:08 kdaccenture

AGP version: 8.5.2 Mapbox Android version: 11.6.0

I can report the same issue with the lint errors. The code compiles and all seams to work as expected, however the lint errors are annoying.

We started seeing this when we migrated from 10.16.1 to 11.6.0

am4-deus avatar Aug 21 '24 14:08 am4-deus

Gradle version: 8.7 AGP version: 8.6.1 Mapbox Android version: 11.4.1 and 11.7.0

Same. Started after updating gradle to 8.7 and AGP to 8.6.1

josh-bartz avatar Oct 03 '24 15:10 josh-bartz

Same. AGP 8.6.1 Kotlin 2.0.21 Mapbox 10.x.x -> 11.6.0 Gradle 8.7

nickdonnelly avatar Oct 24 '24 19:10 nickdonnelly

We ran out of ideas why that particular rule fails. We will disable that lint rule in v11.8.0 coming out next week and revisit it later when we will bump some of our dependencies.

kiryldz avatar Oct 29 '24 09:10 kiryldz