{"record":{"id":"15aa5cae8fd26ae7","repo":"permissions-dispatcher/PermissionsDispatcher","slug":"method-e-simplestring-must-not-have-any-p","errorCode":null,"errorMessage":"Method '${e.simpleString()}()' must not have any parameters","messagePattern":"Method '(.+?)\\(\\)' must not have any parameters","errorType":"validation","errorClass":"NoParametersAllowedException","httpStatus":null,"severity":"error","filePath":"processor/src/main/kotlin/permissions/dispatcher/processor/util/Validators.kt","lineNumber":95,"sourceCode":" */\nfun checkMethodSignature(items: List<ExecutableElement>) {\n    items.forEach {\n        // Allow 'void' return type only\n        if (it.returnType.kind != TypeKind.VOID) {\n            throw WrongReturnTypeException(it)\n        }\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 {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/permissions-dispatcher/PermissionsDispatcher/blob/74b532bf1fe430fb12ad8414b80399f2d7cfc954/processor/src/main/kotlin/permissions/dispatcher/processor/util/Validators.kt#L77-L113","documentation":"Thrown by checkMethodParameters in Validators.kt:95 via NoParametersAllowedException. When the expected parameter count for the annotation is zero, the annotated method must declare no parameters; the generated dispatcher constructs the call itself and has nothing to pass.","triggerScenarios":"Annotating a method that takes parameters with an annotation whose numParams is 0, e.g. @NeedsPermission on fun showCamera(context: Context) or any annotated method with parameters where the annotation expects none.","commonSituations":"Keeping existing method parameters after adding the permission annotation; annotating a helper method with parameters by mistake; misunderstanding that @NeedsPermission methods must be parameterless (use @OnNeverAskAgain-style constants or fields instead).","solutions":["Remove all parameters from the annotated method and access needed values via fields or capture them elsewhere.","Create a parameterless wrapper method that carries the annotation and calls the parameterized helper.","Move to an annotation variant that permits parameters if the library version supports it."],"exampleFix":"// before\n@NeedsPermission(Manifest.permission.CAMERA)\nfun showCamera(activity: Activity) { ... }\n\n// after\n@NeedsPermission(Manifest.permission.CAMERA)\nfun showCamera() { /* use fields/this for context */ }","handlingStrategy":"validation","validationCode":"@NeedsPermission(Manifest.permission.CAMERA)\nfun showCamera() { } // zero parameters for zero-param annotations","typeGuard":null,"tryCatchPattern":"try {\n    build()\n} catch (e: CompilationError) {\n    logger.error(\"Annotated method must not take parameters\", e)\n}","preventionTips":["Keep annotated methods parameterless unless the annotation documents parameters.","Pass context via fields or the enclosing class.","Wrap parameterized logic in a plain helper method."],"tags":["kotlin","annotation-processor","parameters"],"backgroundTag":"missing-required-argument","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"}