Skip to content

Feature suggestion: Fail compile on file contents #46

Closed
@HaasJona

Description

@HaasJona

It's very nice that we can automatically reformat code and replace things with spotless, but we also have sometimes problems that aren't easily fixed by replacements (for example missing license headers (no, just adding them automatically doesn't work because we want to list contributors and so on), usage of prohibited/deprecated classes, swear words in comments and so on.

It would be great if we could do something like

spotless {
		java {
			customFailure 'test', {
                            // it = file contents
                            if(it.contains("java.util.Scanner") {
                                fail('please use BufferedReader instead')
                            }
			}
		}

of course that's a very rough example. The currect "custom" block unfortunately eats all exceptions more or less silently ("Unable to apply step "), else that would be a workaround by just replacing nothing and throwing an exception.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions