{"record":{"id":"51f4443ace4cb4fc","repo":"permissions-dispatcher/PermissionsDispatcher","slug":"method-e-simplestring-must-has-less-than","errorCode":null,"errorMessage":"Method '${e.simpleString()}()' must has less than or equal to $numParams size parameter and type of it is supposed to be '${requiredType.simpleString()}'","messagePattern":"Method '(.+?)\\(\\)' must has less than or equal to \\$numParams size parameter and type of it is supposed to be '(.+?)'","errorType":"validation","errorClass":"WrongParametersException","httpStatus":null,"severity":"error","filePath":"processor/src/main/kotlin/permissions/dispatcher/processor/util/Validators.kt","lineNumber":101,"sourceCode":"        }\n        // Allow methods without 'throws' declaration only\n        if (it.thrownTypes.isNotEmpty()) {\n            throw NoThrowsAllowedException(it)\n        }\n    }\n}\n\nfun checkMethodParameters(items: List<ExecutableElement>, numParams: Int, requiredType: TypeMirror? = null) {\n    items.forEach {\n        val params = it.parameters\n        if (numParams == 0 && params.isNotEmpty()) {\n            throw NoParametersAllowedException(it)\n        }\n        if (requiredType == null) {\n            return\n        }\n        if (numParams < params.size) {\n            throw WrongParametersException(it, numParams, requiredType)\n        }\n        // maximum params size is 1\n        params.forEach { param ->\n            if (!TYPE_UTILS.isSameType(param.asType(), requiredType)) {\n                throw WrongParametersException(it, numParams, requiredType)\n            }\n        }\n    }\n}\n\nfun <A : Annotation> checkMixPermissionType(items: List<ExecutableElement>, annotationClass: Class<A>) {\n    items.forEach {\n        val permissionValue = it.getAnnotation(annotationClass).permissionValue()\n        if (permissionValue.size > 1) {\n            if (permissionValue.contains(WRITE_SETTINGS)) {\n                throw MixPermissionTypeException(it, WRITE_SETTINGS)\n            } else if (permissionValue.contains(SYSTEM_ALERT_WINDOW)) {\n                throw MixPermissionTypeException(it, SYSTEM_ALERT_WINDOW)","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/permissions-dispatcher/PermissionsDispatcher/blob/74b532bf1fe430fb12ad8414b80399f2d7cfc954/processor/src/main/kotlin/permissions/dispatcher/processor/util/Validators.kt#L83-L119","documentation":"Thrown by checkMethodParameters in Validators.kt:101 via WrongParametersException when the method declares more parameters than numParams allows. For annotations allowing at most one parameter, exceeding the count is rejected because the generated dispatcher can only supply a fixed number of arguments.","triggerScenarios":"Annotated method with 2+ parameters while numParams is 1 (or 0), e.g. @OnPermissionDenied fun denied(a: Int, b: String); the check numParams < params.size fires before type checking.","commonSituations":"Adding extra parameters for convenience to a permission callback; merging two callbacks and keeping both parameter lists; misunderstanding the single-permission-string limit of generated methods.","solutions":["Reduce the method to at most numParams parameters (typically one).","Move extra data into class fields or a state object instead of parameters.","Split the method into an annotated minimal method plus an unannotated helper taking the extra parameters."],"exampleFix":"// before\n@OnPermissionDenied\ndef fun onDenied(code: Int, reason: String) { }\n\n// after\n@OnPermissionDenied\ndef fun onDenied(code: Int) { onDeniedInternal(code, reason) }\nprivate fun onDeniedInternal(code: Int, reason: String) { }","handlingStrategy":"validation","validationCode":"@OnPermissionDenied\nfun onDenied(code: Int) { } // at most numParams (1) parameters","typeGuard":null,"tryCatchPattern":"try {\n    build()\n} catch (e: CompilationError) {\n    logger.error(\"Too many parameters on permission callback\", e)\n}","preventionTips":["Limit callbacks to at most one parameter.","Store extra data in fields.","Split large signatures into annotated stub + internal helper."],"tags":["kotlin","annotation-processor","parameters"],"backgroundTag":"argument-out-of-range","analyzedSha":"74b532bf1fe430fb12ad8414b80399f2d7cfc954","analyzedAt":"2026-09-08T21:44:58.380Z","contentChangedAt":"2026-09-08T21:44:58.380Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}