Sonarlint在我的源文件中抱怨许可标头

Gel*_*Luo 7 java sonarqube sonarlint sonarlint-intellij

这是源代码中的许可证标题:

包org.osgl.ut;

/*-
 * #%L
 * Java Unit Test Tool
 * %%
 * Copyright (C) 2017 OSGL (Open Source General Library)
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import static org.hamcrest.Matchers.not;

import org.hamcrest.Matcher;
import org.junit.Assert;
import org.junit.internal.ArrayComparisonFailure;
import org.junit.internal.ExactComparisonCriteria;
import org.junit.internal.InexactComparisonCriteria;

/**
 * The `TestBase` provides simplified assertion methods.
 */
public abstract class TestBase extends Assert {

    /**
     * Asserts that a condition is `true`. If it isn't then throws an
     * {@link AssertionError} with the given message.
     *
     * @param condition
     *              condition to be checked
     * @param message
     *              The error message. `null` Okay
     * @param messageArgs
     *              the error message arguments
     */
    public static void yes(boolean condition, String message, Object ... messageArgs) {
        assertTrue(fmt(message, messageArgs), condition);
    }

    /**
     * Alias of {@link #assertTrue(boolean)}.
     *
     * @param condition condition to be checked
     */
    public static void yes(boolean condition) {
        assertTrue(condition);
    }

    /**
     * Alias of {@link #assertThat(Object, Matcher)}.
     *
     * @param actual
     *              the computed value being compared
     * @param matcher
     *              an expression, built of {@link Matcher}s, specifying allowed values
     * @param <T>
     *              the static type accepted by the matcher (this can flag obvious
     *              compile-time problems such as `yes(1, is("a"))`
     *
     * @see org.hamcrest.CoreMatchers
     * @see org.junit.matchers.JUnitMatchers
     */
    public static <T> void yes(T actual, Matcher<T> matcher) {
        assertThat(actual, matcher);
    }

    /**
     * Require `actual` satisfied the condition specified by `matcher`. If not
     * an {@link AssertionError} is thrown with the reason string and information
     * about the matcher and failing value. Example:
     *
     * ```
     * int n = 0;
     * yes(n, is(not(1))) // passes
     * yes(n, is(1), "Help! Integers don't work"); // fails:
     * // failure message:
     * // Help! Integers don't work
     * // expected: is <1>
     * // got value: <0>
     * ```
     * @param actual the computed value being compared
     * @param matcher an expression, built of {@link Matcher}s, specifying allowed values
     * @param message
     *              additional information about the error
     * @param messageArgs
     *              message arguments
     * @param <T>
     *              the static type accepted by the matcher (this can flag obvious
     *              compile-time problems such as `yes(1, is("a"))`
     *
     * @see org.hamcrest.CoreMatchers
     * @see org.junit.matchers.JUnitMatchers
     */
    public static <T> void yes(T actual, Matcher<T> matcher, String message, Object... messageArgs) {
        if (!matcher.matches(actual)) {
            assertThat(fmt(message, messageArgs), actual, matcher);
        }
    }

    /**
     * Alias of {@link #assertFalse(boolean)}.
     *
     * @param condition condition to be checked
     */
    public static void no(boolean condition) {
        assertFalse(condition);
    }

    /**
     * Asserts that a condition is `false`. If it isn't then throws an
     * {@link AssertionError} with the given message.
     *
     * @param condition
     *              condition to be checked
     * @param message
     *              The error message. `null` Okay
     * @param messageArgs
     *              the error message arguments
     */
    public static void no(boolean condition, String message, Object... messageArgs) {
        assertTrue(String.format(message, messageArgs), !condition);
    }

    /**
     * Require `actual` **NOT** satisfied the condition specified by `matcher`. Otherwise
     * an {@link AssertionError} is thrown with the reason string and information
     * about the matcher and failing value. Example:
     *
     * ```
     * int n = 0;
     * no(n, is(1)) // passes
     * no(n, is(0)); // fails:
     * // failure message:
     * // expected: not is <0>
     * // got value: <0>
     * ```
     *
     * @param actual
     *              the computed value being compared
     * @param matcher
     *              an expression, built of {@link Matcher}s, specifying disallowed values
     * @param <T>
     *              the static type accepted by the matcher (this can flag obvious
     *              compile-time problems such as `no(1, is("a"))`
     *
     * @see org.hamcrest.CoreMatchers
     * @see org.junit.matchers.JUnitMatchers
     */
    public static <T> void no(T actual, Matcher<T> matcher) {
        assertThat(actual, not(matcher));
    }
    ...
Run Code Online (Sandbox Code Playgroud)

当我运行SonarLint时,它说文件中发现了一个问题:

在此输入图像描述

在检查源代码时,如何让SonarLint跳过License标题块?

更新

SonarLint版本:

SonarLint版本:3.0

Sne*_*tel 5

任何评论都会以;原因声纳lint警告结束.

我刚刚;离开Licensed under the Apache License, Version 2.0 (the "License");,sonar lint警告消失了.

  • 是的.尾随的`;`或`{`或`}`产生0.95的"得分"(参见[JavaFootprint.java](https://github.com/SonarSource/sonar-java/blob/4.12.0.11033/java-检查/ src/main/java/org/sonar/java/checks/JavaFootprint.java#L37)),默认阈值为0.9(参见[CommentedOutCodeLineCheck.java](https://github.com/SonarSource/sonar-的java /斑点/ 4.12.0.11033/java的检查/ SRC /主/ JAVA /组织/声纳/ JAVA /检查/ CommentedOutCodeLineCheck.java#L42)).我认为尾随`;`应该具有较低的分数(因此单独不会触发规则). (2认同)