diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/AbstractUiStringCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/AbstractUiStringCheck.java new file mode 100644 index 000000000..18b4be219 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/AbstractUiStringCheck.java @@ -0,0 +1,122 @@ +/** + * + */ +package com.e1c.v8codestyle.md.check; + +import java.text.MessageFormat; +import java.util.regex.Pattern; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.common.util.EMap; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; + +import com._1c.g5.v8.dt.common.StringUtils; +import com._1c.g5.v8.dt.core.platform.IV8ProjectManager; +import com.e1c.g5.v8.dt.check.CheckComplexity; +import com.e1c.g5.v8.dt.check.ICheckParameters; +import com.e1c.g5.v8.dt.check.components.BasicCheck; +import com.e1c.g5.v8.dt.check.settings.IssueSeverity; +import com.e1c.g5.v8.dt.check.settings.IssueType; + +/** + * The abstract class to check UI feature of EMF object that is not empty or match pattern. + * + * @author Dmitriy Marmyshev + */ +public abstract class AbstractUiStringCheck + extends BasicCheck +{ + protected static final String PARAM_UI_STRING_PATTERN = "uiStringPattern"; //$NON-NLS-1$ + + protected final EReference uiStringRef; + + private final IV8ProjectManager v8ProjectManager; + + protected AbstractUiStringCheck(EReference uiStringRef, IV8ProjectManager v8ProjectManager) + { + this.uiStringRef = uiStringRef; + this.v8ProjectManager = v8ProjectManager; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + builder.complexity(CheckComplexity.NORMAL) + .severity(IssueSeverity.MINOR) + .issueType(IssueType.UI_STYLE) + .extension(new MdUiStringExtension()) + .parameter(PARAM_UI_STRING_PATTERN, String.class, getUiStringPatternDefaultValue(), + getUiStringPatternTitle()); + } + + protected String getUiStringPatternDefaultValue() + { + return StringUtils.EMPTY; + } + + protected String getUiStringPatternTitle() + { + return "UI string pattern"; + } + + @Override + protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters, + IProgressMonitor monitor) + { + EObject eObject = (EObject)object; + Object rawValue = eObject.eGet(uiStringRef); + if (!(rawValue instanceof EMap)) + { + return; + } + + @SuppressWarnings("unchecked") + EMap uiString = (EMap)rawValue; + + if (uiString.isEmpty()) + { + resultAceptor.addIssue(getUiStringIsEmptyForAll(), uiStringRef); + } + else + { + String uiStringPatternText = parameters.getString(PARAM_UI_STRING_PATTERN); + Pattern uiStringPattern = StringUtils.isBlank(uiStringPatternText) ? null + : Pattern.compile(uiStringPatternText, Pattern.UNICODE_CHARACTER_CLASS); + + for (String languageCode : MdUiStringExtension.getLanguageCodes(parameters, eObject, v8ProjectManager)) + { + String value = uiString.get(languageCode); + if (StringUtils.isBlank(value)) + { + resultAceptor.addIssue(getUiStringIsEmpty(languageCode), uiStringRef); + } + else + { + if (uiStringPattern != null && !uiStringPattern.matcher(value).matches()) + { + resultAceptor.addIssue(getUiStringShouldMatchPattern(languageCode, uiStringPatternText), + uiStringRef); + } + } + } + } + } + + protected String getUiStringIsEmptyForAll() + { + return "UI string is empty for all languages"; + } + + protected String getUiStringIsEmpty(String languageCode) + { + return MessageFormat.format("UI string for language \"{0}\" is empty", languageCode); + } + + protected String getUiStringShouldMatchPattern(String languageCode, String patternText) + { + return MessageFormat.format("UI string for language \"{0}\" should match pattern: \"{1}\"", languageCode, + patternText); + } + +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/DbObjectAnyRefTypeCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/DbObjectAnyRefTypeCheck.java index a0409d3bd..880a5b786 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/DbObjectAnyRefTypeCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/DbObjectAnyRefTypeCheck.java @@ -76,7 +76,7 @@ protected void configureCheck(CheckConfigurer builder) .severity(IssueSeverity.MAJOR) .issueType(IssueType.PERFORMANCE) .extension(new StandardCheckExtension(728, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(BASIC_DB_OBJECT) .containment(TYPE_DESCRIPTION) .features(TYPE_DESCRIPTION__TYPES); diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/DbObjectMaxNumberLengthCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/DbObjectMaxNumberLengthCheck.java index 696dfdbc9..44696ea3c 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/DbObjectMaxNumberLengthCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/DbObjectMaxNumberLengthCheck.java @@ -72,7 +72,7 @@ protected void configureCheck(CheckConfigurer builder) .severity(IssueSeverity.MAJOR) .issueType(IssueType.PORTABILITY) .extension(new StandardCheckExtension(467, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .parameter(MAX_LENGTH, Integer.class, MAX_LENGTH_DEFAULT, Messages.DbObjectMaxNumberLengthCheck_parameter); builder.topObject(BASIC_DB_OBJECT) diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/DbObjectRefNonRefTypesCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/DbObjectRefNonRefTypesCheck.java index fe61dd3b4..3fae321e8 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/DbObjectRefNonRefTypesCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/DbObjectRefNonRefTypesCheck.java @@ -86,7 +86,7 @@ protected void configureCheck(CheckConfigurer builder) .severity(IssueSeverity.MAJOR) .issueType(IssueType.PERFORMANCE) .extension(new StandardCheckExtension(728, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(BASIC_DB_OBJECT) .containment(TYPE_DESCRIPTION) .features(TYPE_DESCRIPTION__TYPES); diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdListObjectPresentationCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdListObjectPresentationCheck.java index 5f71d23a3..bf8bb1708 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdListObjectPresentationCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdListObjectPresentationCheck.java @@ -85,7 +85,7 @@ protected void configureCheck(CheckConfigurer builder) .extension(new TopObjectFilterExtension()) .issueType(IssueType.UI_STYLE) .extension(new StandardCheckExtension(468, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()); + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()); builder.topObject(BASIC_DB_OBJECT) .checkTop() diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectAttributeCommentCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectAttributeCommentCheck.java index 69e791a4c..849b18989 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectAttributeCommentCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectAttributeCommentCheck.java @@ -84,7 +84,7 @@ protected void configureCheck(CheckConfigurer builder) .severity(IssueSeverity.MINOR) .issueType(IssueType.UI_STYLE) .extension(new StandardCheckExtension(531, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .extension(new TopObjectFilterExtension()) .parameter(PARAM_ATTRIBUTES_LIST, String.class, DEFAULT_ATTRIBUTES_LIST, Messages.MdObjectAttributeCommentCheck_Attribute_list); diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectAttributeCommentNotExistCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectAttributeCommentNotExistCheck.java index f0af9c129..c4bc844c4 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectAttributeCommentNotExistCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectAttributeCommentNotExistCheck.java @@ -81,7 +81,7 @@ protected void configureCheck(CheckConfigurer builder) .severity(IssueSeverity.MINOR) .issueType(IssueType.UI_STYLE) .extension(new StandardCheckExtension(531, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .extension(new TopObjectFilterExtension()) .parameter(PARAM_ATTRIBUTE_NAMES_LIST, String.class, DEFAULT_ATTRIBUTE_NAMES_LIST, Messages.MdObjectAttributeCommentNotExist_Param_Attribute_name_list); diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectNameLength.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectNameLength.java index e03057301..60750cb74 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectNameLength.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectNameLength.java @@ -60,7 +60,7 @@ protected void configureCheck(CheckConfigurer builder) .extension(new TopObjectFilterExtension()) .issueType(IssueType.PORTABILITY) .extension(new CommonSenseCheckExtension(getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(MD_OBJECT) .checkTop() .features(MD_OBJECT__NAME) diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectNameUnallowedLetterCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectNameUnallowedLetterCheck.java index 6702696ba..0de781b6e 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectNameUnallowedLetterCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectNameUnallowedLetterCheck.java @@ -59,7 +59,7 @@ protected void configureCheck(CheckConfigurer builder) .extension(new TopObjectFilterExtension()) .issueType(IssueType.UI_STYLE) .extension(new StandardCheckExtension(474, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(MD_OBJECT) .features(MD_OBJECT__NAME, MD_OBJECT__SYNONYM, MD_OBJECT__COMMENT); } diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectSynonymCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectSynonymCheck.java new file mode 100644 index 000000000..69b3c04ae --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectSynonymCheck.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright (C) 2021, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.md.check; + +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.MD_OBJECT; +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.MD_OBJECT__SYNONYM; + +import java.text.MessageFormat; + +import org.eclipse.core.runtime.IProgressMonitor; + +import com._1c.g5.v8.dt.core.platform.IV8ProjectManager; +import com._1c.g5.v8.dt.metadata.mdclass.Configuration; +import com.e1c.g5.v8.dt.check.ICheckParameters; +import com.e1c.v8codestyle.check.StandardCheckExtension; +import com.e1c.v8codestyle.internal.md.CorePlugin; +import com.google.inject.Inject; + +/** + * Check MD object synonym should not be empty or should match a pattern + * + * @author Dmitriy Marmyshev + */ +public final class MdObjectSynonymCheck + extends AbstractUiStringCheck +{ + private static final String CHECK_ID = "mdo-synonym"; //$NON-NLS-1$ + + @Inject + public MdObjectSynonymCheck(IV8ProjectManager v8ProjectManager) + { + super(MD_OBJECT__SYNONYM, v8ProjectManager); + } + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + super.configureCheck(builder); + builder.title("Metada object synonym") + .description("Metada object synonym") + .extension(new StandardCheckExtension(474, getCheckId(), CorePlugin.PLUGIN_ID)) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) + .topObject(MD_OBJECT) + .checkTop() + .features(MD_OBJECT__SYNONYM); + } + + @Override + protected String getUiStringPatternTitle() + { + return "Synonym pattern"; + } + + @Override + protected String getUiStringIsEmptyForAll() + { + return "Synonym is empty for all languages"; + } + + @Override + protected String getUiStringIsEmpty(String languageCode) + { + return MessageFormat.format("Synonym for language \"{0}\" is empty", languageCode); + } + + @Override + protected String getUiStringShouldMatchPattern(String languageCode, String patternText) + { + return MessageFormat.format("Synonym for language \"{0}\" should match pattern: \"{1}\"", languageCode, + patternText); + } + + @Override + protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters, + IProgressMonitor monitor) + { + if (object instanceof Configuration) + { + // Skip here, there is another synonym check for Configuration + return; + } + super.check(object, resultAceptor, parameters, monitor); + } + +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdStandardAttributeSynonymEmpty.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdStandardAttributeSynonymEmpty.java index 704fd2540..e23445bd1 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdStandardAttributeSynonymEmpty.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdStandardAttributeSynonymEmpty.java @@ -95,7 +95,7 @@ protected void configureCheck(CheckConfigurer builder) .issueType(IssueType.UI_STYLE) .extension(new TopObjectFilterExtension()) .extension(new StandardCheckExtension(474, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .extension(new CatalogChangeExtension()); builder.topObject(CATALOG).containment(STANDARD_ATTRIBUTE).features(STANDARD_ATTRIBUTE__SYNONYM); diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdUiStringExtension.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdUiStringExtension.java new file mode 100644 index 000000000..a687c849e --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdUiStringExtension.java @@ -0,0 +1,95 @@ +/** + * + */ +package com.e1c.v8codestyle.md.check; + +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import org.eclipse.emf.ecore.EObject; + +import com._1c.g5.v8.dt.common.StringUtils; +import com._1c.g5.v8.dt.core.platform.IExtensionProject; +import com._1c.g5.v8.dt.core.platform.IV8Project; +import com._1c.g5.v8.dt.core.platform.IV8ProjectManager; +import com._1c.g5.v8.dt.metadata.mdclass.Configuration; +import com._1c.g5.v8.dt.metadata.mdclass.Language; +import com.e1c.g5.v8.dt.check.CheckParameterDefinition; +import com.e1c.g5.v8.dt.check.ICheckDefinition; +import com.e1c.g5.v8.dt.check.ICheckParameters; +import com.e1c.g5.v8.dt.check.components.IBasicCheckExtension; + +/** + * @author Dmitriy Marmyshev + * + */ +public class MdUiStringExtension + implements IBasicCheckExtension +{ + + public static final String CHECK_LANGUAGES_PARAMETER_NAME = "checkLanguages"; //$NON-NLS-1$ + public static final String CHECK_ALL_LANGUAGES = "all"; //$NON-NLS-1$ + public static final String CHECK_DEFAUL_LANGUAGE = "default"; //$NON-NLS-1$ + + private final String parameterName; + private final List defaultValue; + private final String parameterTitle; + + + public MdUiStringExtension() + { + this(CHECK_LANGUAGES_PARAMETER_NAME, + "List of language codes to check, or \"all\" for all or \"default\" for main language", + List.of(CHECK_DEFAUL_LANGUAGE)); + } + + public MdUiStringExtension(final String parameterName, final String parameterTitle, final List defaultValue) + { + this.parameterName = parameterName; + this.parameterTitle = parameterTitle; + this.defaultValue = defaultValue; + } + + @Override + public void configureContextCollector(final ICheckDefinition definition) + { + final CheckParameterDefinition parameterDefinition = new CheckParameterDefinition(this.parameterName, + String.class, String.join(",", this.defaultValue), this.parameterTitle); //$NON-NLS-1$ + definition.addParameterDefinition(parameterDefinition); + } + + public static Collection getLanguageCodes(ICheckParameters parameters, EObject context, + IV8ProjectManager v8ProjectManager) + { + String value = parameters.getString(CHECK_LANGUAGES_PARAMETER_NAME); + Set languageCodes = value == null ? Set.of() : Set.of(value.replace(" ", StringUtils.EMPTY).split(",")); //$NON-NLS-1$ //$NON-NLS-2$ + + if (languageCodes.contains(CHECK_ALL_LANGUAGES)) + { + IV8Project v8Project = v8ProjectManager.getProject(context); + return v8Project.getLanguages().stream().map(Language::getLanguageCode).collect(Collectors.toSet()); + + } + else if (languageCodes.contains(CHECK_DEFAUL_LANGUAGE)) + { + IV8Project v8Project = v8ProjectManager.getProject(context); + Language language = v8Project.getDefaultLanguage(); + if (language == null && v8Project instanceof IExtensionProject) + { + Configuration configuration = ((IExtensionProject)v8Project).getConfiguration(); + if (configuration != null) + { + language = configuration.getDefaultLanguage(); + } + } + return language == null ? Set.of() : Set.of(language.getLanguageCode()); + } + else + { + return languageCodes; + } + } + +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/SkipAdoptedInExtensionMdObjectExtension.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/SkipAdoptedInExtensionMdObjectExtension.java index 2b43035f5..e47ad9a3b 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/SkipAdoptedInExtensionMdObjectExtension.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/SkipAdoptedInExtensionMdObjectExtension.java @@ -25,6 +25,22 @@ public class SkipAdoptedInExtensionMdObjectExtension implements IBasicCheckExtension { + private static IBasicCheckExtension instance; + + public static synchronized IBasicCheckExtension instance() + { + if (instance == null) + { + instance = new SkipAdoptedInExtensionMdObjectExtension(); + } + return instance; + } + + private SkipAdoptedInExtensionMdObjectExtension() + { + // empty + } + @Override public ITopObjectFilter contributeTopObjectFilter() { diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameCachedCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameCachedCheck.java index 82119ac15..55bc94cf7 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameCachedCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameCachedCheck.java @@ -77,7 +77,7 @@ protected void configureCheck(CheckConfigurer builder) .issueType(IssueType.WARNING) .extension(new StandardCheckExtension(469, getCheckId(), CorePlugin.PLUGIN_ID)) .extension(new TopObjectFilterExtension()) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(COMMON_MODULE) .checkTop() .features(MD_OBJECT__NAME, COMMON_MODULE__RETURN_VALUES_REUSE); diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameClient.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameClient.java index dc336c0ae..579aca6b5 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameClient.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameClient.java @@ -76,7 +76,7 @@ protected void configureCheck(CheckConfigurer builder) .extension(new TopObjectFilterExtension()) .extension(new MdObjectNameWithoutSuffix(NAME_SUFFIX_DEFAULT)) .extension(new StandardCheckExtension(469, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(COMMON_MODULE) .checkTop() .features(MD_OBJECT__NAME, diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameClientCachedCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameClientCachedCheck.java index 9fdbc674a..ccd9ac10c 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameClientCachedCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameClientCachedCheck.java @@ -77,7 +77,7 @@ protected void configureCheck(CheckConfigurer builder) .issueType(IssueType.WARNING) .extension(new StandardCheckExtension(469, getCheckId(), CorePlugin.PLUGIN_ID)) .extension(new TopObjectFilterExtension()) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(COMMON_MODULE) .checkTop() .features(MD_OBJECT__NAME, COMMON_MODULE__RETURN_VALUES_REUSE); diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameClientServer.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameClientServer.java index bc898970a..0a2f45eb2 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameClientServer.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameClientServer.java @@ -77,7 +77,7 @@ protected void configureCheck(CheckConfigurer builder) .extension(new TopObjectFilterExtension()) .extension(new MdObjectNameWithoutSuffix(NAME_SUFFIX_DEFAULT)) .extension(new StandardCheckExtension(469, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(COMMON_MODULE) .checkTop() .features(MD_OBJECT__NAME, diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameGlobal.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameGlobal.java index 2cb24e782..fb6ae37ed 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameGlobal.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameGlobal.java @@ -76,7 +76,7 @@ protected void configureCheck(CheckConfigurer builder) .extension(new TopObjectFilterExtension()) .extension(new MdObjectNameWithoutSuffix(NAME_SUFFIX_DEFAULT)) .extension(new StandardCheckExtension(469, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(COMMON_MODULE) .checkTop() .features(MD_OBJECT__NAME, diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameGlobalClientCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameGlobalClientCheck.java index 876d4a8bd..a7795a89d 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameGlobalClientCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameGlobalClientCheck.java @@ -31,6 +31,7 @@ import com.e1c.g5.v8.dt.check.settings.IssueType; import com.e1c.v8codestyle.check.StandardCheckExtension; import com.e1c.v8codestyle.internal.md.CorePlugin; +import com.e1c.v8codestyle.md.check.SkipAdoptedInExtensionMdObjectExtension; import com.google.inject.Inject; /** @@ -75,6 +76,7 @@ protected void configureCheck(CheckConfigurer builder) .severity(IssueSeverity.CRITICAL) .issueType(IssueType.WARNING) .extension(new StandardCheckExtension(469, getCheckId(), CorePlugin.PLUGIN_ID)) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(COMMON_MODULE) .checkTop() .features(MD_OBJECT__NAME, COMMON_MODULE__GLOBAL); diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNamePrivilegedCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNamePrivilegedCheck.java index 16b2cb170..3cb11ace8 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNamePrivilegedCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNamePrivilegedCheck.java @@ -62,7 +62,7 @@ protected void configureCheck(CheckConfigurer builder) .extension(new TopObjectFilterExtension()) .extension(new MdObjectNameWithoutSuffix(NAME_SUFFIX_DEFAULT)) .extension(new StandardCheckExtension(469, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(COMMON_MODULE) .checkTop() .features(MD_OBJECT__NAME, COMMON_MODULE__PRIVILEGED); diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameServerCallCachedCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameServerCallCachedCheck.java index 566e93ee9..3313e6dd3 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameServerCallCachedCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameServerCallCachedCheck.java @@ -77,7 +77,7 @@ protected void configureCheck(CheckConfigurer builder) .issueType(IssueType.WARNING) .extension(new StandardCheckExtension(469, getCheckId(), CorePlugin.PLUGIN_ID)) .extension(new TopObjectFilterExtension()) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(COMMON_MODULE) .checkTop() .features(MD_OBJECT__NAME, COMMON_MODULE__RETURN_VALUES_REUSE); diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameServerCallCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameServerCallCheck.java index 75f9f7699..2a4aa54b9 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameServerCallCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleNameServerCallCheck.java @@ -76,7 +76,7 @@ protected void configureCheck(CheckConfigurer builder) .issueType(IssueType.WARNING) .extension(new StandardCheckExtension(469, getCheckId(), CorePlugin.PLUGIN_ID)) .extension(new TopObjectFilterExtension()) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(COMMON_MODULE) .checkTop() .features(MD_OBJECT__NAME, COMMON_MODULE__SERVER_CALL); diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleType.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleType.java index 6d8e08a1a..64e551a3d 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleType.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/commonmodule/check/CommonModuleType.java @@ -86,7 +86,7 @@ protected void configureCheck(CheckConfigurer builder) .issueType(IssueType.CODE_STYLE) .extension(new TopObjectFilterExtension()) .extension(new StandardCheckExtension(469, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(COMMON_MODULE) .checkTop() .features(CommonModuleTypes.SERVER.getFeatureValues(false).keySet().toArray(new EStructuralFeature[0])); diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationBriefInformationCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationBriefInformationCheck.java new file mode 100644 index 000000000..bcfdc4a0c --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationBriefInformationCheck.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (C) 2021, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.md.configuration.check; + +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION; +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION__BRIEF_INFORMATION; + +import java.text.MessageFormat; + +import com._1c.g5.v8.dt.core.platform.IV8ProjectManager; +import com.e1c.v8codestyle.check.StandardCheckExtension; +import com.e1c.v8codestyle.internal.md.CorePlugin; +import com.e1c.v8codestyle.md.check.AbstractUiStringCheck; +import com.google.inject.Inject; + +/** + * Check configuration version should match a pattern + * + * @author Dmitriy Marmyshev + */ +public final class ConfigurationBriefInformationCheck + extends AbstractUiStringCheck +{ + private static final String CHECK_ID = "configuration-brief-information"; //$NON-NLS-1$ + private static final String PARAM_PATTERN_DEFAULT = ""; //$NON-NLS-1$ + + @Inject + public ConfigurationBriefInformationCheck(IV8ProjectManager v8ProjectManager) + { + super(CONFIGURATION__BRIEF_INFORMATION, v8ProjectManager); + } + + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + super.configureCheck(builder); + builder.title("Configuration brief information") + .description("Configuration brief information") + .extension(new StandardCheckExtension(482, getCheckId(), CorePlugin.PLUGIN_ID)) + .topObject(CONFIGURATION) + .checkTop() + .features(CONFIGURATION__BRIEF_INFORMATION); + } + + @Override + protected String getUiStringPatternDefaultValue() + { + return PARAM_PATTERN_DEFAULT; + } + + @Override + protected String getUiStringPatternTitle() + { + return "Pattern"; + } + + @Override + protected String getUiStringIsEmptyForAll() + { + return "Brief information is empty for all languages"; + } + + @Override + protected String getUiStringIsEmpty(String languageCode) + { + return MessageFormat.format("Brief information for language \"{0}\" is empty", languageCode); + } + + @Override + protected String getUiStringShouldMatchPattern(String languageCode, String patternText) + { + return MessageFormat.format("Brief information for language \"{0}\" should match pattern: \"{1}\"", + languageCode, patternText); + } + +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationCopyrightCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationCopyrightCheck.java new file mode 100644 index 000000000..116b1b4c6 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationCopyrightCheck.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (C) 2021, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.md.configuration.check; + +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION; +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION__COPYRIGHT; + +import java.text.MessageFormat; + +import com._1c.g5.v8.dt.core.platform.IV8ProjectManager; +import com.e1c.v8codestyle.check.StandardCheckExtension; +import com.e1c.v8codestyle.internal.md.CorePlugin; +import com.e1c.v8codestyle.md.check.AbstractUiStringCheck; +import com.google.inject.Inject; + +/** + * Check configuration version should match a pattern + * + * @author Dmitriy Marmyshev + */ +public final class ConfigurationCopyrightCheck + extends AbstractUiStringCheck +{ + private static final String CHECK_ID = "configuration-copyright"; //$NON-NLS-1$ + private static final String PARAM_PATTERN_DEFAULT = + "Copyright \\(C\\) .*, \\d{4}\\-\\d{4}. (All rights reserved|Все права защищены)\\."; //$NON-NLS-1$ + + @Inject + public ConfigurationCopyrightCheck(IV8ProjectManager v8ProjectManager) + { + super(CONFIGURATION__COPYRIGHT, v8ProjectManager); + } + + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + super.configureCheck(builder); + builder.title("Configuration copyright") + .description("Configuration copyright") + .extension(new StandardCheckExtension(482, getCheckId(), CorePlugin.PLUGIN_ID)) + .topObject(CONFIGURATION) + .checkTop() + .features(CONFIGURATION__COPYRIGHT); + } + + @Override + protected String getUiStringPatternDefaultValue() + { + return PARAM_PATTERN_DEFAULT; + } + + @Override + protected String getUiStringPatternTitle() + { + return "Copyright pattern"; + } + + @Override + protected String getUiStringIsEmptyForAll() + { + return "Copyright is empty for all languages"; + } + + @Override + protected String getUiStringIsEmpty(String languageCode) + { + return MessageFormat.format("Copyright for language \"{0}\" is empty", languageCode); + } + + @Override + protected String getUiStringShouldMatchPattern(String languageCode, String patternText) + { + return MessageFormat.format("Copyright for language \"{0}\" should match pattern: \"{1}\"", languageCode, + patternText); + } +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationDataLock.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationDataLock.java index e6834ebcb..4226504d7 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationDataLock.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationDataLock.java @@ -17,9 +17,6 @@ import org.eclipse.core.runtime.IProgressMonitor; -import com._1c.g5.v8.dt.core.platform.IConfigurationProject; -import com._1c.g5.v8.dt.core.platform.IV8Project; -import com._1c.g5.v8.dt.core.platform.IV8ProjectManager; import com._1c.g5.v8.dt.metadata.mdclass.Configuration; import com._1c.g5.v8.dt.metadata.mdclass.DefaultDataLockControlMode; import com.e1c.g5.v8.dt.check.CheckComplexity; @@ -29,7 +26,7 @@ import com.e1c.g5.v8.dt.check.settings.IssueType; import com.e1c.v8codestyle.check.StandardCheckExtension; import com.e1c.v8codestyle.internal.md.CorePlugin; -import com.google.inject.Inject; +import com.e1c.v8codestyle.md.check.SkipAdoptedInExtensionMdObjectExtension; /** * Check configuration data lock mode should be managed @@ -42,14 +39,6 @@ public final class ConfigurationDataLock private static final String CHECK_ID = "configuration-data-lock-mode"; //$NON-NLS-1$ - private final IV8ProjectManager v8ProjectManager; - - @Inject - public ConfigurationDataLock(IV8ProjectManager v8ProjectManager) - { - this.v8ProjectManager = v8ProjectManager; - } - @Override public String getCheckId() { @@ -65,6 +54,7 @@ protected void configureCheck(CheckConfigurer builder) .severity(IssueSeverity.MAJOR) .issueType(IssueType.PERFORMANCE) .extension(new StandardCheckExtension(460, getCheckId(), CorePlugin.PLUGIN_ID)) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(CONFIGURATION) .checkTop() .features(CONFIGURATION__DATA_LOCK_CONTROL_MODE); @@ -75,9 +65,7 @@ protected void check(Object object, ResultAcceptor resultAceptor, ICheckParamete IProgressMonitor monitor) { Configuration configuration = (Configuration)object; - IV8Project v8Project = v8ProjectManager.getProject(configuration); - if (v8Project instanceof IConfigurationProject - && DefaultDataLockControlMode.MANAGED != configuration.getDataLockControlMode()) + if (DefaultDataLockControlMode.MANAGED != configuration.getDataLockControlMode()) { resultAceptor.addIssue(Messages.ConfigurationDataLock_message, CONFIGURATION__DATA_LOCK_CONTROL_MODE); } diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationDetailedInformationCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationDetailedInformationCheck.java new file mode 100644 index 000000000..da016c01a --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationDetailedInformationCheck.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (C) 2021, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.md.configuration.check; + +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION; +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION__DETAILED_INFORMATION; + +import java.text.MessageFormat; + +import com._1c.g5.v8.dt.core.platform.IV8ProjectManager; +import com.e1c.v8codestyle.check.StandardCheckExtension; +import com.e1c.v8codestyle.internal.md.CorePlugin; +import com.e1c.v8codestyle.md.check.AbstractUiStringCheck; +import com.google.inject.Inject; + +/** + * Check configuration version should match a pattern + * + * @author Dmitriy Marmyshev + */ +public final class ConfigurationDetailedInformationCheck + extends AbstractUiStringCheck +{ + + private static final String CHECK_ID = "configuration-detailed-information"; //$NON-NLS-1$ + private static final String PARAM_PATTERN_DEFAULT = ""; //$NON-NLS-1$ + + @Inject + public ConfigurationDetailedInformationCheck(IV8ProjectManager v8ProjectManager) + { + super(CONFIGURATION__DETAILED_INFORMATION, v8ProjectManager); + } + + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + super.configureCheck(builder); + builder.title("Configuration detailed information") + .description("Configuration detailed information") + .extension(new StandardCheckExtension(482, getCheckId(), CorePlugin.PLUGIN_ID)) + .topObject(CONFIGURATION) + .checkTop() + .features(CONFIGURATION__DETAILED_INFORMATION); + } + + @Override + protected String getUiStringPatternDefaultValue() + { + return PARAM_PATTERN_DEFAULT; + } + + @Override + protected String getUiStringPatternTitle() + { + return "Pattern"; + } + + @Override + protected String getUiStringIsEmptyForAll() + { + return "Detailed information is empty for all languages"; + } + + @Override + protected String getUiStringIsEmpty(String languageCode) + { + return MessageFormat.format("Detailed information for language \"{0}\" is empty", languageCode); + } + + @Override + protected String getUiStringShouldMatchPattern(String languageCode, String patternText) + { + return MessageFormat.format("Detailed information for language \"{0}\" should match pattern: \"{1}\"", + languageCode, patternText); + } + +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationInformationAddressCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationInformationAddressCheck.java new file mode 100644 index 000000000..147ed2d4a --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationInformationAddressCheck.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (C) 2021, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.md.configuration.check; + +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION; +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION__CONFIGURATION_INFORMATION_ADDRESS; + +import java.text.MessageFormat; + +import com._1c.g5.v8.dt.core.platform.IV8ProjectManager; +import com.e1c.v8codestyle.check.StandardCheckExtension; +import com.e1c.v8codestyle.internal.md.CorePlugin; +import com.e1c.v8codestyle.md.check.AbstractUiStringCheck; +import com.google.inject.Inject; + +/** + * Check configuration version should match a pattern + * + * @author Dmitriy Marmyshev + */ +public final class ConfigurationInformationAddressCheck + extends AbstractUiStringCheck +{ + private static final String CHECK_ID = "configuration-information-address"; //$NON-NLS-1$ + private static final String PARAM_PATTERN_DEFAULT = ""; //$NON-NLS-1$ + + @Inject + public ConfigurationInformationAddressCheck(IV8ProjectManager v8ProjectManager) + { + super(CONFIGURATION__CONFIGURATION_INFORMATION_ADDRESS, v8ProjectManager); + } + + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + super.configureCheck(builder); + builder.title("Configuration information address") + .description("Configuration information address") + .extension(new StandardCheckExtension(482, getCheckId(), CorePlugin.PLUGIN_ID)) + .topObject(CONFIGURATION) + .checkTop() + .features(CONFIGURATION__CONFIGURATION_INFORMATION_ADDRESS); + } + + @Override + protected String getUiStringPatternDefaultValue() + { + return PARAM_PATTERN_DEFAULT; + } + + @Override + protected String getUiStringPatternTitle() + { + return "Address pattern"; + } + + @Override + protected String getUiStringIsEmptyForAll() + { + return "Configuration information address is empty for all languages"; + } + + @Override + protected String getUiStringIsEmpty(String languageCode) + { + return MessageFormat.format("Configuration information address for language \"{0}\" is empty", languageCode); + } + + @Override + protected String getUiStringShouldMatchPattern(String languageCode, String patternText) + { + return MessageFormat.format( + "Configuration information address for language \"{0}\" should match pattern: \"{1}\"", languageCode, + patternText); + } + +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationNameCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationNameCheck.java new file mode 100644 index 000000000..221c6d6bb --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationNameCheck.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (C) 2021, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.md.configuration.check; + +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION; +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.MD_OBJECT__NAME; + +import java.text.MessageFormat; +import java.util.regex.Pattern; + +import org.eclipse.core.runtime.IProgressMonitor; + +import com._1c.g5.v8.dt.common.StringUtils; +import com._1c.g5.v8.dt.metadata.mdclass.Configuration; +import com.e1c.g5.v8.dt.check.CheckComplexity; +import com.e1c.g5.v8.dt.check.ICheckParameters; +import com.e1c.g5.v8.dt.check.components.BasicCheck; +import com.e1c.g5.v8.dt.check.settings.IssueSeverity; +import com.e1c.g5.v8.dt.check.settings.IssueType; +import com.e1c.v8codestyle.check.StandardCheckExtension; +import com.e1c.v8codestyle.internal.md.CorePlugin; + +/** + * Check configuration version should match a pattern + * + * @author Dmitriy Marmyshev + */ +public final class ConfigurationNameCheck + extends BasicCheck +{ + + private static final String CHECK_ID = "configuration-name"; //$NON-NLS-1$ + private static final String PARAM_VERSION_PATTERN = "namePattern"; //$NON-NLS-1$ + private static final String PARAM_VERSION_PATTERN_DEFAULT = ""; //$NON-NLS-1$ + + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + builder.title("") + .description("") + .complexity(CheckComplexity.NORMAL) + .severity(IssueSeverity.MAJOR) + .issueType(IssueType.CODE_STYLE) + .extension(new StandardCheckExtension(482, getCheckId(), CorePlugin.PLUGIN_ID)) + .topObject(CONFIGURATION) + .checkTop() + .features(MD_OBJECT__NAME) + .parameter(PARAM_VERSION_PATTERN, String.class, PARAM_VERSION_PATTERN_DEFAULT, "Version pattern"); + } + + @Override + protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters, + IProgressMonitor monitor) + { + Configuration configuration = (Configuration)object; + String name = configuration.getName(); + + if (StringUtils.isBlank(name)) + { + resultAceptor.addIssue("Name is blank", MD_OBJECT__NAME); + } + else + { + String namePattern = parameters.getString(PARAM_VERSION_PATTERN); + if (!StringUtils.isBlank(namePattern) + && Pattern.compile(namePattern, Pattern.UNICODE_CHARACTER_CLASS).matcher(name).matches()) + { + String message = MessageFormat.format("Name \"{0}\" should match pattern: \"{1}\"", name, namePattern); + resultAceptor.addIssue(message, MD_OBJECT__NAME); + } + } + } + +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationSynonymCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationSynonymCheck.java new file mode 100644 index 000000000..9b6975acd --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationSynonymCheck.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (C) 2021, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.md.configuration.check; + +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION; +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.MD_OBJECT__SYNONYM; + +import java.text.MessageFormat; + +import com._1c.g5.v8.dt.core.platform.IV8ProjectManager; +import com.e1c.v8codestyle.check.StandardCheckExtension; +import com.e1c.v8codestyle.internal.md.CorePlugin; +import com.e1c.v8codestyle.md.check.AbstractUiStringCheck; +import com.google.inject.Inject; + +/** + * Check configuration version should match a pattern + * + * @author Dmitriy Marmyshev + */ +public final class ConfigurationSynonymCheck + extends AbstractUiStringCheck +{ + private static final String CHECK_ID = "configuration-synonym"; //$NON-NLS-1$ + private static final String PARAM_SYNONYM_PATTERN_DEFAULT = ".*, (edition|редакция) \\d+\\.\\d+$"; //$NON-NLS-1$ + + @Inject + public ConfigurationSynonymCheck(IV8ProjectManager v8ProjectManager) + { + super(MD_OBJECT__SYNONYM, v8ProjectManager); + } + + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + super.configureCheck(builder); + builder.title("Configuration synonym") + .description("Configuration synonym") + .extension(new StandardCheckExtension(482, getCheckId(), CorePlugin.PLUGIN_ID)) + .topObject(CONFIGURATION) + .checkTop() + .features(MD_OBJECT__SYNONYM); + } + + @Override + protected String getUiStringPatternDefaultValue() + { + return PARAM_SYNONYM_PATTERN_DEFAULT; + } + + @Override + protected String getUiStringPatternTitle() + { + return "Synonym pattern"; + } + + @Override + protected String getUiStringIsEmptyForAll() + { + return "Synonym is empty for all languages"; + } + + @Override + protected String getUiStringIsEmpty(String languageCode) + { + return MessageFormat.format("Synonym for language \"{0}\" is empty", languageCode); + } + + @Override + protected String getUiStringShouldMatchPattern(String languageCode, String patternText) + { + return MessageFormat.format("Synonym for language \"{0}\" should match pattern: \"{1}\"", languageCode, + patternText); + } + +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationUpdateCatalogAddressCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationUpdateCatalogAddressCheck.java new file mode 100644 index 000000000..4b8709bb5 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationUpdateCatalogAddressCheck.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (C) 2021, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.md.configuration.check; + +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION; +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION__UPDATE_CATALOG_ADDRESS; + +import java.text.MessageFormat; +import java.util.regex.Pattern; + +import org.eclipse.core.runtime.IProgressMonitor; + +import com._1c.g5.v8.dt.common.StringUtils; +import com._1c.g5.v8.dt.metadata.mdclass.Configuration; +import com.e1c.g5.v8.dt.check.CheckComplexity; +import com.e1c.g5.v8.dt.check.ICheckParameters; +import com.e1c.g5.v8.dt.check.components.BasicCheck; +import com.e1c.g5.v8.dt.check.settings.IssueSeverity; +import com.e1c.g5.v8.dt.check.settings.IssueType; +import com.e1c.v8codestyle.check.StandardCheckExtension; +import com.e1c.v8codestyle.internal.md.CorePlugin; + +/** + * Check configuration version should match a pattern + * + * @author Dmitriy Marmyshev + */ +public final class ConfigurationUpdateCatalogAddressCheck + extends BasicCheck +{ + + private static final String CHECK_ID = "configuration-update-catalog-address"; //$NON-NLS-1$ + private static final String PARAM_PATTERN = "addressPattern"; //$NON-NLS-1$ + private static final String PARAM_PATTERN_DEFAULT = ""; //$NON-NLS-1$ + + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + builder.title("Configuration Update catalod address") + .description("Configuration Update catalod address") + .complexity(CheckComplexity.NORMAL) + .severity(IssueSeverity.MAJOR) + .issueType(IssueType.CODE_STYLE) + .extension(new StandardCheckExtension(482, getCheckId(), CorePlugin.PLUGIN_ID)) + .topObject(CONFIGURATION) + .checkTop() + .features(CONFIGURATION__UPDATE_CATALOG_ADDRESS) + .parameter(PARAM_PATTERN, String.class, PARAM_PATTERN_DEFAULT, "Address pattern"); + } + + @Override + protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters, + IProgressMonitor monitor) + { + Configuration configuration = (Configuration)object; + String address = configuration.getUpdateCatalogAddress(); + + if (StringUtils.isBlank(address)) + { + resultAceptor.addIssue("Update catalod address is blank", CONFIGURATION__UPDATE_CATALOG_ADDRESS); + } + else + { + String addressPattern = parameters.getString(PARAM_PATTERN); + if (!StringUtils.isBlank(addressPattern) + && Pattern.compile(addressPattern, Pattern.UNICODE_CHARACTER_CLASS).matcher(address).matches()) + { + String message = MessageFormat.format("Update catalod address \"{0}\" should match pattern: \"{1}\"", + address, addressPattern); + resultAceptor.addIssue(message, CONFIGURATION__UPDATE_CATALOG_ADDRESS); + } + } + } + +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationUseManagedFormsCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationUseManagedFormsCheck.java new file mode 100644 index 000000000..217ea6327 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationUseManagedFormsCheck.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (C) 2021, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.md.configuration.check; + +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION; +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION__USE_MANAGED_FORM_IN_ORDINARY_APPLICATION; + +import org.eclipse.core.runtime.IProgressMonitor; + +import com._1c.g5.v8.dt.metadata.mdclass.Configuration; +import com.e1c.g5.v8.dt.check.CheckComplexity; +import com.e1c.g5.v8.dt.check.ICheckParameters; +import com.e1c.g5.v8.dt.check.components.BasicCheck; +import com.e1c.g5.v8.dt.check.settings.IssueSeverity; +import com.e1c.g5.v8.dt.check.settings.IssueType; +import com.e1c.v8codestyle.check.StandardCheckExtension; +import com.e1c.v8codestyle.internal.md.CorePlugin; +import com.e1c.v8codestyle.md.check.SkipAdoptedInExtensionMdObjectExtension; + +/** + * Check configuration should set use managed forms in ordinary application. + * + * @author Dmitriy Marmyshev + */ +public final class ConfigurationUseManagedFormsCheck + extends BasicCheck +{ + private static final String CHECK_ID = "configuration-use-managed-form-in-ordinary-application"; //$NON-NLS-1$ + + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + builder.title("Configuration use managed forms in ordinary application") + .description("Configuration use managed forms in ordinary application") + .complexity(CheckComplexity.NORMAL) + .severity(IssueSeverity.MAJOR) + .issueType(IssueType.PERFORMANCE) + .extension(new StandardCheckExtension(467, getCheckId(), CorePlugin.PLUGIN_ID)) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) + .topObject(CONFIGURATION) + .checkTop() + .features(CONFIGURATION__USE_MANAGED_FORM_IN_ORDINARY_APPLICATION); + } + + @Override + protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters, + IProgressMonitor monitor) + { + Configuration configuration = (Configuration)object; + if (!configuration.isUseManagedFormInOrdinaryApplication()) + { + resultAceptor.addIssue("Configuration should use managed forms in ordinary application", + CONFIGURATION__USE_MANAGED_FORM_IN_ORDINARY_APPLICATION); + } + } + +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationVendorCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationVendorCheck.java new file mode 100644 index 000000000..c18269ea2 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationVendorCheck.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (C) 2021, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.md.configuration.check; + +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION; +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION__VENDOR; + +import java.text.MessageFormat; +import java.util.regex.Pattern; + +import org.eclipse.core.runtime.IProgressMonitor; + +import com._1c.g5.v8.dt.common.StringUtils; +import com._1c.g5.v8.dt.metadata.mdclass.Configuration; +import com.e1c.g5.v8.dt.check.CheckComplexity; +import com.e1c.g5.v8.dt.check.ICheckParameters; +import com.e1c.g5.v8.dt.check.components.BasicCheck; +import com.e1c.g5.v8.dt.check.settings.IssueSeverity; +import com.e1c.g5.v8.dt.check.settings.IssueType; +import com.e1c.v8codestyle.check.StandardCheckExtension; +import com.e1c.v8codestyle.internal.md.CorePlugin; + +/** + * Check configuration vendor should match a pattern + * + * @author Dmitriy Marmyshev + */ +public final class ConfigurationVendorCheck + extends BasicCheck +{ + private static final String CHECK_ID = "configuration-vendor"; //$NON-NLS-1$ + private static final String PARAM_VENDOR_PATTERN = "vendorPattern"; //$NON-NLS-1$ + + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + builder.title("") + .description("") + .complexity(CheckComplexity.NORMAL) + .severity(IssueSeverity.MAJOR) + .issueType(IssueType.CODE_STYLE) + .extension(new StandardCheckExtension(482, getCheckId(), CorePlugin.PLUGIN_ID)) + .topObject(CONFIGURATION) + .checkTop() + .features(CONFIGURATION__VENDOR) + .parameter(PARAM_VENDOR_PATTERN, String.class, StringUtils.EMPTY, "Vendor pattern"); + } + + @Override + protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters, + IProgressMonitor monitor) + { + Configuration configuration = (Configuration)object; + String vendor = configuration.getVendor(); + + if (StringUtils.isBlank(vendor)) + { + resultAceptor.addIssue("Vendor is blank", CONFIGURATION__VENDOR); + } + else + { + String vendorPattern = parameters.getString(PARAM_VENDOR_PATTERN); + if (!StringUtils.isBlank(vendorPattern) + && Pattern.compile(vendorPattern, Pattern.UNICODE_CHARACTER_CLASS).matcher(vendor).matches()) + { + String message = + MessageFormat.format("Vendor \"{0}\" should match pattern: \"{1}\"", vendor, vendorPattern); + resultAceptor.addIssue(message, CONFIGURATION__VENDOR); + } + } + } + +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationVendorInformationAddressCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationVendorInformationAddressCheck.java new file mode 100644 index 000000000..6c5bdc10b --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationVendorInformationAddressCheck.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (C) 2021, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.md.configuration.check; + +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION; +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION__VENDOR_INFORMATION_ADDRESS; + +import java.text.MessageFormat; + +import com._1c.g5.v8.dt.core.platform.IV8ProjectManager; +import com.e1c.v8codestyle.check.StandardCheckExtension; +import com.e1c.v8codestyle.internal.md.CorePlugin; +import com.e1c.v8codestyle.md.check.AbstractUiStringCheck; +import com.google.inject.Inject; + +/** + * Check configuration version should match a pattern + * + * @author Dmitriy Marmyshev + */ +public final class ConfigurationVendorInformationAddressCheck + extends AbstractUiStringCheck +{ + + private static final String CHECK_ID = "configuration-vendor-information-address"; //$NON-NLS-1$ + private static final String PARAM_PATTERN_DEFAULT = ""; //$NON-NLS-1$ + + @Inject + public ConfigurationVendorInformationAddressCheck(IV8ProjectManager v8ProjectManager) + { + super(CONFIGURATION__VENDOR_INFORMATION_ADDRESS, v8ProjectManager); + } + + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + super.configureCheck(builder); + builder.title("Vendor information address") + .description("Vendor information address") + .extension(new StandardCheckExtension(482, getCheckId(), CorePlugin.PLUGIN_ID)) + .topObject(CONFIGURATION) + .checkTop() + .features(CONFIGURATION__VENDOR_INFORMATION_ADDRESS); + } + + @Override + protected String getUiStringPatternDefaultValue() + { + return PARAM_PATTERN_DEFAULT; + } + + @Override + protected String getUiStringPatternTitle() + { + return "Address pattern"; + } + + @Override + protected String getUiStringIsEmptyForAll() + { + return "Vendor information address is empty for all languages"; + } + + @Override + protected String getUiStringIsEmpty(String languageCode) + { + return MessageFormat.format("Vendor information address for language \"{0}\" is empty", languageCode); + } + + @Override + protected String getUiStringShouldMatchPattern(String languageCode, String patternText) + { + return MessageFormat.format("Vendor information address for language \"{0}\" should match pattern: \"{1}\"", + languageCode, patternText); + } + +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationVersionCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationVersionCheck.java new file mode 100644 index 000000000..c76c8e41d --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/ConfigurationVersionCheck.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (C) 2021, 1C-Soft LLC and others. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * 1C-Soft LLC - initial API and implementation + *******************************************************************************/ +package com.e1c.v8codestyle.md.configuration.check; + +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION; +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION__VERSION; + +import java.text.MessageFormat; +import java.util.regex.Pattern; + +import org.eclipse.core.runtime.IProgressMonitor; + +import com._1c.g5.v8.dt.common.StringUtils; +import com._1c.g5.v8.dt.metadata.mdclass.Configuration; +import com.e1c.g5.v8.dt.check.CheckComplexity; +import com.e1c.g5.v8.dt.check.ICheckParameters; +import com.e1c.g5.v8.dt.check.components.BasicCheck; +import com.e1c.g5.v8.dt.check.settings.IssueSeverity; +import com.e1c.g5.v8.dt.check.settings.IssueType; +import com.e1c.v8codestyle.check.StandardCheckExtension; +import com.e1c.v8codestyle.internal.md.CorePlugin; + +/** + * Check configuration version should match a pattern + * + * @author Dmitriy Marmyshev + */ +public final class ConfigurationVersionCheck + extends BasicCheck +{ + + private static final String CHECK_ID = "configuration-version"; //$NON-NLS-1$ + private static final String PARAM_VERSION_PATTERN = "versionPattern"; //$NON-NLS-1$ + private static final String PARAM_VERSION_PATTERN_DEFAULT = + "^([1-9]|\\d{2,})\\.\\d{1,2}\\.([1-9]|\\d{2,})\\.([1-9]|\\d{2,})$"; //$NON-NLS-1$ + + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + builder.title("Configuration version format") + .description("Configuration version format") + .complexity(CheckComplexity.NORMAL) + .severity(IssueSeverity.MAJOR) + .issueType(IssueType.CODE_STYLE) + .extension(new StandardCheckExtension(483, getCheckId(), CorePlugin.PLUGIN_ID)) + .topObject(CONFIGURATION) + .checkTop() + .features(CONFIGURATION__VERSION) + .parameter(PARAM_VERSION_PATTERN, String.class, PARAM_VERSION_PATTERN_DEFAULT, "Version pattern"); + } + + @Override + protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters, + IProgressMonitor monitor) + { + Configuration configuration = (Configuration)object; + String version = configuration.getVersion(); + + if (StringUtils.isBlank(version)) + { + resultAceptor.addIssue("Version is blank", CONFIGURATION__VERSION); + } + else + { + String versionPattern = parameters.getString(PARAM_VERSION_PATTERN); + if (!StringUtils.isBlank(versionPattern) + && !Pattern.compile(versionPattern, Pattern.UNICODE_CHARACTER_CLASS).matcher(version).matches()) + { + String message = + MessageFormat.format("Version \"{0}\" should match pattern: \"{1}\"", version, versionPattern); + resultAceptor.addIssue(message, CONFIGURATION__VERSION); + } + } + } + +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/Messages.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/Messages.java index 1197f779b..48e525151 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/Messages.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/configuration/check/Messages.java @@ -14,7 +14,6 @@ import org.eclipse.osgi.util.NLS; - /** * @author Dmitriy Marmyshev * diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/document/check/DocumentPostInPrivilegedModeCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/document/check/DocumentPostInPrivilegedModeCheck.java index c20b8b06f..42aa6626c 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/document/check/DocumentPostInPrivilegedModeCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/document/check/DocumentPostInPrivilegedModeCheck.java @@ -64,7 +64,7 @@ protected void configureCheck(CheckConfigurer builder) .severity(IssueSeverity.MAJOR) .issueType(IssueType.WARNING) .extension(new StandardCheckExtension(689, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(DOCUMENT) .checkTop() .features(DOCUMENT__POSTING, DOCUMENT__POST_IN_PRIVILEGED_MODE, DOCUMENT__UNPOST_IN_PRIVILEGED_MODE, diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/functionoption/check/FunctionalOptionPrivilegedGetModeCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/functionoption/check/FunctionalOptionPrivilegedGetModeCheck.java index 3bcabf9d7..70c4522d3 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/functionoption/check/FunctionalOptionPrivilegedGetModeCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/functionoption/check/FunctionalOptionPrivilegedGetModeCheck.java @@ -59,7 +59,7 @@ protected void configureCheck(CheckConfigurer builder) .severity(IssueSeverity.MAJOR) .issueType(IssueType.WARNING) .extension(new StandardCheckExtension(689, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(FUNCTIONAL_OPTION) .checkTop() .features(FUNCTIONAL_OPTION__PRIVILEGED_GET_MODE, FUNCTIONAL_OPTION__LOCATION); diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/scheduledjob/check/MdScheduledJobDescriptionCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/scheduledjob/check/MdScheduledJobDescriptionCheck.java index 4fecdfb0e..ba235f824 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/scheduledjob/check/MdScheduledJobDescriptionCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/scheduledjob/check/MdScheduledJobDescriptionCheck.java @@ -57,7 +57,7 @@ protected void configureCheck(CheckConfigurer builder) .severity(IssueSeverity.MINOR) .issueType(IssueType.UI_STYLE) .extension(new StandardCheckExtension(767, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(SCHEDULED_JOB) .checkTop() .features(SCHEDULED_JOB__DESCRIPTION, SCHEDULED_JOB__PREDEFINED); diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/scheduledjob/check/MdScheduledJobPeriodicityCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/scheduledjob/check/MdScheduledJobPeriodicityCheck.java index 60a1fb600..beb12ff94 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/scheduledjob/check/MdScheduledJobPeriodicityCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/scheduledjob/check/MdScheduledJobPeriodicityCheck.java @@ -125,7 +125,7 @@ protected void configureCheck(CheckConfigurer builder) .severity(IssueSeverity.MAJOR) .issueType(IssueType.PERFORMANCE) .extension(new StandardCheckExtension(402, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .topObject(SCHEDULE) .checkTop() .containment(DAILY_SCHEDULE) diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/subsystem/check/SubsystemSynonymTooLongCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/subsystem/check/SubsystemSynonymTooLongCheck.java index a94836900..58a7915c5 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/subsystem/check/SubsystemSynonymTooLongCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/subsystem/check/SubsystemSynonymTooLongCheck.java @@ -74,7 +74,7 @@ protected void configureCheck(CheckConfigurer builder) .severity(IssueSeverity.MINOR) .extension(new TopObjectFilterExtension()) .extension(new StandardCheckExtension(712, getCheckId(), CorePlugin.PLUGIN_ID)) - .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .extension(SkipAdoptedInExtensionMdObjectExtension.instance()) .issueType(IssueType.UI_STYLE) .topObject(SUBSYSTEM) .checkTop()