• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jreleaser / jreleaser / #486

23 May 2025 05:11PM UTC coverage: 48.584% (-0.09%) from 48.67%
#486

push

github

aalmiray
feat(core): Add a flag to skip non-configured sections. The yolo flag.

Closes #1840

160 of 217 new or added lines in 57 files covered. (73.73%)

438 existing lines in 34 files now uncovered.

25292 of 52058 relevant lines covered (48.58%)

0.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

31.75
/api/jreleaser-utils/src/main/java/org/jreleaser/util/Errors.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 *
4
 * Copyright 2020-2025 The JReleaser authors.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     https://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
package org.jreleaser.util;
19

20
import org.jreleaser.logging.JReleaserLogger;
21

22
import java.io.PrintWriter;
23
import java.io.Serializable;
24
import java.io.StringWriter;
25
import java.util.LinkedHashSet;
26
import java.util.Objects;
27
import java.util.Set;
28

29
/**
30
 * @author Andres Almiray
31
 * @since 0.2.0
32
 */
33
public class Errors implements Serializable {
1✔
34
    private static final long serialVersionUID = -3601667298659606426L;
35

36
    private final Set<Error> assemblyErrors = new LinkedHashSet<>();
1✔
37
    private final Set<Error> configurationErrors = new LinkedHashSet<>();
1✔
38
    private final Set<Error> warnings = new LinkedHashSet<>();
1✔
39

40
    public Errors merge(Errors other) {
NEW
41
        this.assemblyErrors.addAll(other.assemblyErrors);
×
NEW
42
        this.configurationErrors.addAll(other.configurationErrors);
×
NEW
43
        this.warnings.addAll(other.warnings);
×
44

NEW
45
        return this;
×
46
    }
47

48
    public Errors clear() {
NEW
49
        this.assemblyErrors.clear();
×
NEW
50
        this.configurationErrors.clear();
×
NEW
51
        this.warnings.clear();
×
52

NEW
53
        return this;
×
54
    }
55

56
    public Errors mergeAsWarnings(Errors other) {
NEW
57
        this.warnings.addAll(other.assemblyErrors);
×
NEW
58
        this.warnings.addAll(other.configurationErrors);
×
NEW
59
        this.warnings.addAll(other.warnings);
×
60

NEW
61
        return this;
×
62
    }
63

64
    public boolean hasErrors() {
65
        return !assemblyErrors.isEmpty() || !configurationErrors.isEmpty();
1✔
66
    }
67

68
    public boolean hasAssemblyErrors() {
69
        return !assemblyErrors.isEmpty();
×
70
    }
71

72
    public boolean hasConfigurationErrors() {
73
        return !configurationErrors.isEmpty();
1✔
74
    }
75

76
    public boolean hasWarnings() {
77
        return !warnings.isEmpty();
1✔
78
    }
79

80
    public void assembly(String message) {
81
        assemblyErrors.add(new Error(Kind.ASSEMBLY, message));
×
82
    }
×
83

84
    public void configuration(String message) {
85
        configurationErrors.add(new Error(Kind.CONFIGURATION, message));
1✔
86
    }
1✔
87

88
    public void warning(String message) {
89
        warnings.add(new Error(Kind.CONFIGURATION, message));
1✔
90
    }
1✔
91

92
    public void logWarnings(JReleaserLogger logger) {
UNCOV
93
        warnings.forEach(e -> logger.warn(e.message));
×
UNCOV
94
    }
×
95

96
    public void logWarnings(PrintWriter writer) {
97
        warnings.forEach(e -> writer.println(e.message));
×
98
    }
×
99

100
    public void logErrors(JReleaserLogger logger) {
101
        assemblyErrors.forEach(e -> logger.error(e.message));
×
102
        configurationErrors.forEach(e -> logger.error(e.message));
×
103
    }
×
104

105
    public void logErrors(PrintWriter writer) {
106
        assemblyErrors.forEach(e -> writer.println(e.message));
×
107
        configurationErrors.forEach(e -> writer.println(e.message));
×
108
    }
×
109

110
    public String asString() {
111
        StringWriter writer = new StringWriter();
×
112
        logErrors(new PrintWriter(writer));
×
113
        return writer.toString();
×
114
    }
115

116
    public String warningsAsString() {
117
        StringWriter writer = new StringWriter();
×
118
        logWarnings(new PrintWriter(writer));
×
119
        return writer.toString();
×
120
    }
121

122
    public void addAll(Errors errors) {
123
        this.assemblyErrors.addAll(errors.assemblyErrors);
×
124
        this.configurationErrors.addAll(errors.configurationErrors);
×
125
        this.warnings.addAll(errors.warnings);
×
126
    }
×
127

128
    public enum Kind {
1✔
129
        ASSEMBLY,
1✔
130
        CONFIGURATION,
1✔
131
        WARNING
1✔
132
    }
133

134
    public static class Error implements Serializable {
135
        private static final long serialVersionUID = -9011553489507569322L;
136

137
        private final Kind kind;
138
        private final String message;
139

140
        public Error(Kind kind, String message) {
1✔
141
            this.kind = kind;
1✔
142
            this.message = message;
1✔
143
        }
1✔
144

145
        public Kind getKind() {
146
            return kind;
×
147
        }
148

149
        public String getMessage() {
150
            return message;
×
151
        }
152

153
        @Override
154
        public boolean equals(Object o) {
155
            if (this == o) return true;
×
156
            if (null == o || getClass() != o.getClass()) return false;
×
157
            Error error = (Error) o;
×
158
            return kind == error.kind &&
×
159
                message.equals(error.message);
×
160
        }
161

162
        @Override
163
        public int hashCode() {
164
            return Objects.hash(kind, message);
1✔
165
        }
166

167
        @Override
168
        public String toString() {
169
            return message;
×
170
        }
171
    }
172
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc