Skip to content

Commit

Permalink
Create dedicated linter types
Browse files Browse the repository at this point in the history
  • Loading branch information
tibetiroka committed Feb 28, 2024
1 parent 2204ad4 commit c6ebbb9
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 113 deletions.
15 changes: 7 additions & 8 deletions src/main/java/com/tibetiroka/deblint/ControlType.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
package com.tibetiroka.deblint;

import java.util.List;
import java.util.function.BiConsumer;

/**
* The types of supported control files. THey each have a description for use with {@code --type-info}, and their own linter configurations.
Expand All @@ -29,21 +28,21 @@ public enum ControlType {
/**
* The file-wide linter for this type.
*/
private final BiConsumer<ControlFile, Configuration> linter;
private final FileLinter linter;
/**
* The list of stanzas that can appear in this type, in their expected order.
*/
private final List<StanzaSpec> stanzas;
/**
* The debian standard name for this control file type.
*/
private final String typeName;
/**
* Whether the file supports OpenPGP signatures.
*/
private final boolean supportsPgp;
/**
* The debian standard name for this control file type.
*/
private final String typeName;

private ControlType(String typeName, String defaultFile, String description, List<StanzaSpec> stanzas, BiConsumer<ControlFile, Configuration> linter, boolean supportsPgp) {
private ControlType(String typeName, String defaultFile, String description, List<StanzaSpec> stanzas, FileLinter linter, boolean supportsPgp) {
this.typeName = typeName;
this.defaultFile = defaultFile;
this.description = description;
Expand Down Expand Up @@ -76,7 +75,7 @@ public String getDescription() {
*
* @return {@link #linter}
*/
public BiConsumer<ControlFile, Configuration> getLinter() {
public FileLinter getLinter() {
return linter;
}

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/tibetiroka/deblint/FieldLinter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2024 by tibetiroka.
*
* debian-control-linter is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* debian-control-linter is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.tibetiroka.deblint;

import java.util.function.BiConsumer;

@FunctionalInterface
public interface FieldLinter extends BiConsumer<String, Configuration> {
}
4 changes: 1 addition & 3 deletions src/main/java/com/tibetiroka/deblint/FieldSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@

package com.tibetiroka.deblint;

import java.util.function.BiConsumer;

/**
* Specification for a field.
*
* @param required Whether the field is required, recommended or is completely optional.
* @param type The type of this field, as the stanza requires it
* @param linter The linter used for the value of this field
*/
public record FieldSpec(RequirementStatus required, FieldType type, BiConsumer<String, Configuration> linter) {
public record FieldSpec(RequirementStatus required, FieldType type, FieldLinter linter) {
/**
* The importance of a data field. {@link #MANDATORY mandatory} fields are required for a {@link StanzaSpec} to apply to a parsed {@link Stanza},
*/
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/tibetiroka/deblint/FileLinter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 by tibetiroka.
*
* debian-control-linter is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* debian-control-linter is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.tibetiroka.deblint;

import java.util.function.BiConsumer;

public interface FileLinter extends BiConsumer<ControlFile, Configuration> {
}
Loading

0 comments on commit c6ebbb9

Please sign in to comment.