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

Cognifide / AEM-Rules-for-SonarQube / #809

29 Oct 2024 02:17PM UTC coverage: 93.59% (-0.2%) from 93.816%
#809

push

tomasz-strzelecki-wttech
Update dependencies to use on SonarQube 10.7 version

625 of 758 branches covered (82.45%)

3 of 9 new or added lines in 3 files covered. (33.33%)

1606 of 1716 relevant lines covered (93.59%)

0.94 hits per line

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

0.0
/src/main/java/com/vml/aemrules/java/rules/JavaCheckRegistrar.java
1
/*-
2
 * #%L
3
 * AEM Rules for SonarQube
4
 * %%
5
 * Copyright (C) 2015-2024 VML
6
 * %%
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *      http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 * #L%
19
 */
20
package com.vml.aemrules.java.rules;
21

22
import com.vml.aemrules.version.AemVersion;
23
import com.vml.aemrules.version.VersionSupportChecker;
24
import org.sonar.api.config.Configuration;
25
import org.sonar.plugins.java.api.CheckRegistrar;
26
import org.sonar.plugins.java.api.JavaCheck;
27
import org.sonarsource.api.sonarlint.SonarLintSide;
28

29
import java.util.List;
30
import java.util.Optional;
31
import java.util.stream.Collectors;
32

33
import static com.vml.aemrules.java.Constants.REPOSITORY_KEY;
34

35
@SonarLintSide
36
public class JavaCheckRegistrar implements CheckRegistrar {
37

38
    private final String aemVersion;
39

40
    public JavaCheckRegistrar(Configuration configuration) {
×
41
        this.aemVersion = configuration.get(VersionSupportChecker.VERSION_PROPERTY)
×
42
                .orElse(VersionSupportChecker.DEFAULT_AEM_VERSION);
×
43
    }
×
44

45
    @Override
46
    public void register(RegistrarContext registrarContext) {
47
        registrarContext.registerClassesForRepository(REPOSITORY_KEY, checkClasses(), testCheckClasses());
×
48
    }
×
49

50
    private List<Class<? extends JavaCheck>> checkClasses() {
51
        return JavaRulesList.getJavaChecks().stream()
×
52
                .filter(checkClass -> shouldRegister(aemVersion, checkClass))
×
NEW
53
                .toList();
×
54
    }
55

56
    private List<Class<? extends JavaCheck>> testCheckClasses() {
57
        return JavaRulesList.getJavaTestChecks().stream()
×
58
                .filter(checkClass -> shouldRegister(aemVersion, checkClass))
×
NEW
59
                .toList();
×
60
    }
61

62
    private boolean shouldRegister(String aemVersion, Class<? extends JavaCheck> checkClass) {
63
        return Optional.ofNullable(checkClass.getAnnotation(AemVersion.class))
×
64
                .map(supportedVersion -> VersionSupportChecker.create(supportedVersion).supports(aemVersion))
×
65
                .orElse(true);
×
66
    }
67
}
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