All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.thomasjensen.checkstyle.addons.sonarqube.RegexpOnStringRule Maven / Gradle / Ivy

The newest version!
package com.thomasjensen.checkstyle.addons.sonarqube;
/*
 * Checkstyle-Addons - Additional Checkstyle checks
 * Copyright (c) 2015-2022, the Checkstyle Addons contributors
 *
 * This program is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License, version 3, as published by the Free
 * Software Foundation.
 *
 * This program 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 .
 */

import javax.annotation.Nonnull;

import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
import org.sonar.api.server.rule.RuleParamType;


/**
 * SonarQube rule for our RegexpOnString check.
 */
public class RegexpOnStringRule
    extends AbstractRuleBase
{
    public RegexpOnStringRule(@Nonnull final NewRepository pSqRepo, @Nonnull final String pCheckstyleAddonsVersion)
    {
        super(pSqRepo, pCheckstyleAddonsVersion, true);
    }



    @Nonnull
    @Override
    protected String getRuleId()
    {
        return "com.thomasjensen.checkstyle.addons.checks.regexp.RegexpOnStringCheck";
    }



    @Override
    protected void defineRule(@Nonnull final NewRule pNewRule, @Nonnull final String pCheckstyleAddonsVersion)
    {
        pNewRule.setName("Regexp On String")
            .setInternalKey("Checker/TreeWalker/RegexpOnString")
            .setHtmlDescription("

Checks String literals against a regular expression. Matching Strings are flagged" + ".

\n

Full Documentation

") .setSeverity(Severity.MAJOR) .setStatus(RuleStatus.READY) .setTags("checkstyle-addons", "regexp") .setTemplate(true); pNewRule.setDebtRemediationFunction(pNewRule.debtRemediationFunctions().constantPerIssue("1h")); pNewRule.createParam("regexp") .setType(RuleParamType.STRING) .setDescription("The regular expression used to find Strings to flag.") .setDefaultValue("^(?!x)x"); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy