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

smartsheet / smartsheet-java-sdk / #44

25 Aug 2023 05:39PM UTC coverage: 50.55% (+0.1%) from 50.427%
#44

push

github-actions

web-flow
Fix remaining Checkstyle violations and Enable Checkstyle (#58)

* Fix remaining Checkstyle violations and Enable Checkstyle

We are now down to `20` checkstyle violations in main and `0` violations in test.

The remaining 20 violations are not trivial to fix, so I've set checkstyle to allow those 20 violations to exist, but to fail the build if we ever exceed 20 violations. This should make the build fail if any new violations are added.

For tests, we do not allow _any_ violations. This means adding a single violation will fail the build. Once the 20 violations in main are cleaned up, we can make main and test have the same config.

Note: This MR also changes our PR pipeline to run `./gradlew clean build` instead of `./gradlew clean test`. The reason for this is that build runs all the tests and performs all the other checks (such as checkstyle), whereas `test` didn't run checkstyle and we wouldn't have noticed violations until we tried to deploy.

148 of 148 new or added lines in 24 files covered. (100.0%)

3448 of 6821 relevant lines covered (50.55%)

0.51 hits per line

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

39.29
/src/main/java/com/smartsheet/api/Trace.java
1
package com.smartsheet.api;
2

3
/*
4
 * #[license]
5
 * Smartsheet Java SDK
6
 * %%
7
 * Copyright (C) 2023 Smartsheet
8
 * %%
9
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 *      http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20
 * %[license]
21
 */
22

23
import org.slf4j.LoggerFactory;
24

25
import java.util.Collections;
26
import java.util.HashSet;
27
import java.util.Set;
28

29
/**
30
 * this enum is used to control what from the HTTP request and response is logged
31
 */
32
public enum Trace {
1✔
33
    RequestHeaders,
1✔
34
    RequestBody,
1✔
35
    RequestBodySummary,
1✔
36
    ResponseHeaders,
1✔
37
    ResponseBody,
1✔
38
    ResponseBodySummary,
1✔
39
    Request {
1✔
40
        @Override
41
        public boolean addReplacements(Set<Trace> traces) {
42
            traces.add(RequestHeaders);
×
43
            traces.add(RequestBodySummary);
×
44
            return true;
×
45
        }
46
    },
47
    Response {
1✔
48
        @Override
49
        public boolean addReplacements(Set<Trace> traces) {
50
            traces.add(ResponseHeaders);
×
51
            traces.add(ResponseBodySummary);
×
52
            return true;
×
53
        }
54
    },
55
    ;
56
    // this makes it possible to add other (or additional) Traces for specific types
57
    public boolean addReplacements(Set<Trace> traces) {
58
        return false;
×
59
    }
60

61
    /**
62
     * Parse the string into a Set of Traces
63
     */
64
    public static Set<Trace> parse(String traces) {
65
        if (traces == null || traces.trim().isEmpty()) {
1✔
66
            return Collections.emptySet();
1✔
67
        }
68
        String[] parts = traces.split("[, ]+");
×
69
        // pad for load-factor
70
        Set<Trace> results = new HashSet<>(parts.length + parts.length / 2);
×
71
        for (String part : parts) {
×
72
            try {
73
                Trace trace = valueOf(part);
×
74
                if (!trace.addReplacements(results)) {
×
75
                    results.add(trace);
×
76
                }
77
            } catch (IllegalArgumentException iax) {
×
78
                LoggerFactory.getLogger(Trace.class).warn("invalid trace in parse() - '{}'", part);
×
79
            }
×
80
        }
81
        return results.size() > 0 ? results : Collections.<Trace>emptySet();
×
82
    }
83
}
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

© 2025 Coveralls, Inc