diff --git a/CHANGELOG.md b/CHANGELOG.md index 728a04f5..fed6f98a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Документ не имеет реквизита "Комментарий" - Реквизит "Комментарий" имеет корректный тип - В документе, предполагающем проведение, не установлен флаг "Привилегированный режим при проведении / отмене проведения" +- Проверка наличия буквы "ё" в имени, синониме или комментарии объекта метаданных #### Формы diff --git a/bundles/com.e1c.v8codestyle.md/markdown/mdo-ru-name-unallowed-letter.md b/bundles/com.e1c.v8codestyle.md/markdown/mdo-ru-name-unallowed-letter.md new file mode 100644 index 00000000..1d020803 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/markdown/mdo-ru-name-unallowed-letter.md @@ -0,0 +1,12 @@ +# Check Russian Yo letter "ё" in the name, synonym or comment of metadata object + +In Russian locale, it is not allowed to use the letter "ё" in names, synonyms and comments of metadata objects. + + +## Noncompliant Code Example + +## Compliant Solution + +## See + +[Name, synonym, and comment (in Russian)](https://its.1c.ru/db/v8std#content:474:hdoc) diff --git a/bundles/com.e1c.v8codestyle.md/markdown/ru/mdo-ru-name-unallowed-letter.md b/bundles/com.e1c.v8codestyle.md/markdown/ru/mdo-ru-name-unallowed-letter.md new file mode 100644 index 00000000..c68d7085 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/markdown/ru/mdo-ru-name-unallowed-letter.md @@ -0,0 +1,12 @@ +# Проверка наличия буквы "ё" в имени, синониме или комментарии объекта метаданных + +В именах, синонимах и комментариях объектов метаданных не допускается использовать букву "ё". + + +## Неправильно + +## Правильно + +## См. + +[Имя, синоним, комментарий](https://its.1c.ru/db/v8std#content:474:hdoc) diff --git a/bundles/com.e1c.v8codestyle.md/plugin.xml b/bundles/com.e1c.v8codestyle.md/plugin.xml index 3b6b75df..d269874d 100644 --- a/bundles/com.e1c.v8codestyle.md/plugin.xml +++ b/bundles/com.e1c.v8codestyle.md/plugin.xml @@ -110,6 +110,10 @@ category="com.e1c.v8codestyle.md" class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.check.ExtensionMdObjectNamePrefixCheck"> + + @@ -123,5 +127,5 @@ class="com.e1c.v8codestyle.md.check.MdObjectAttributeCommentNotExistCheck"> - - + + \ No newline at end of file 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 new file mode 100644 index 00000000..6702696b --- /dev/null +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdObjectNameUnallowedLetterCheck.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (C) 2022, 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__COMMENT; +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.MD_OBJECT__NAME; +import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.MD_OBJECT__SYNONYM; + +import org.eclipse.core.runtime.IProgressMonitor; + +import com._1c.g5.v8.dt.metadata.mdclass.MdObject; +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.components.TopObjectFilterExtension; +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 in Russian locale, names, synonyms and comments of metadata objects do not contain the letter "ё". + * + * @author Olga Bozhko + */ +public class MdObjectNameUnallowedLetterCheck + extends BasicCheck +{ + private static final String CHECK_ID = "mdo-ru-name-unallowed-letter"; //$NON-NLS-1$ + private static final String LANGUAGE_KEY_RU = "ru"; //$NON-NLS-1$ + private static final String UNALLOWED_LETTER = "ё"; //$NON-NLS-1$ + private static final String ISSUE_MESSAGE = + Messages.MdObjectNameUnallowedLetterCheck_Ru_locale_unallowed_letter_used_for_name_synonym_or_comment; + + @Override + public String getCheckId() + { + return CHECK_ID; + } + + @Override + protected void configureCheck(CheckConfigurer builder) + { + builder.title(Messages.MdObjectNameUnallowedLetterCheck_title) + .description(Messages.MdObjectNameUnallowedLetterCheck_description) + .complexity(CheckComplexity.NORMAL) + .severity(IssueSeverity.MINOR) + .extension(new TopObjectFilterExtension()) + .issueType(IssueType.UI_STYLE) + .extension(new StandardCheckExtension(474, getCheckId(), CorePlugin.PLUGIN_ID)) + .extension(new SkipAdoptedInExtensionMdObjectExtension()) + .topObject(MD_OBJECT) + .features(MD_OBJECT__NAME, MD_OBJECT__SYNONYM, MD_OBJECT__COMMENT); + } + + @Override + protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters, + IProgressMonitor monitor) + { + MdObject mdObject = (MdObject)object; + if (hasUnallowedLetter(mdObject.getName())) + { + resultAceptor.addIssue(ISSUE_MESSAGE, MD_OBJECT__NAME); + } + if (hasUnallowedLetter(mdObject.getSynonym().get(LANGUAGE_KEY_RU))) + { + resultAceptor.addIssue(ISSUE_MESSAGE, MD_OBJECT__SYNONYM); + } + if (hasUnallowedLetter(mdObject.getComment())) + { + resultAceptor.addIssue(ISSUE_MESSAGE, MD_OBJECT__COMMENT); + } + } + + private static boolean hasUnallowedLetter(String testableString) + { + return testableString != null && testableString.contains(UNALLOWED_LETTER); + + } +} diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/Messages.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/Messages.java index d29db4e4..010afc3a 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/Messages.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/Messages.java @@ -76,6 +76,9 @@ final class Messages public static String MdObjectNameLength_Maximum_name_length_description; public static String MdObjectNameLength_message; public static String MdObjectNameLength_title; + public static String MdObjectNameUnallowedLetterCheck_description; + public static String MdObjectNameUnallowedLetterCheck_Ru_locale_unallowed_letter_used_for_name_synonym_or_comment; + public static String MdObjectNameUnallowedLetterCheck_title; public static String MdListObjectPresentationCheck_decription; public static String MdListObjectPresentationCheck_Neither_Object_presentation_nor_List_presentation_is_not_filled; public static String MdListObjectPresentationCheck_title; diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/messages.properties b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/messages.properties index 28bdc876..f76f6abd 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/messages.properties +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/messages.properties @@ -111,6 +111,12 @@ MdObjectNameLength_message = Metadata object name should be less then {0} MdObjectNameLength_title = Metadata object name length +MdObjectNameUnallowedLetterCheck_Ru_locale_unallowed_letter_used_for_name_synonym_or_comment = In Russian locale, name, synonym or comment of metadata object contain the unallowed letter + +MdObjectNameUnallowedLetterCheck_description = In Russian locale name, synonym or comment of metadata object contain the unallowed letter + +MdObjectNameUnallowedLetterCheck_title = In Russian locale name, synonym or comment of metadata object contain the unallowed letter + MdObjectNameWithoutSuffix_Name_suffix_list_title = Name suffix list, comma separated MdOwnerAttributeSynonymEmpty_Description = Synonym of the 'Owner' or 'Parent' standard attribute is not specified diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/messages_ru.properties b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/messages_ru.properties index b473a3cb..b0f3b417 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/messages_ru.properties +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/messages_ru.properties @@ -112,6 +112,12 @@ MdObjectNameLength_message = Длина имени объекта метадан MdObjectNameLength_title = Длина имени объекта метаданных +MdObjectNameUnallowedLetterCheck_Ru_locale_unallowed_letter_used_for_name_synonym_or_comment = Имя, синоним или комментарий содержит букву “ё” + +MdObjectNameUnallowedLetterCheck_description = Имя, синоним или комментарий содержит букву “ё” + +MdObjectNameUnallowedLetterCheck_title = Имя, синоним или комментарий содержит букву “ё” + MdObjectNameWithoutSuffix_Name_suffix_list_title = Список суффиксов имени, разделенный запятой MdOwnerAttributeSynonymEmpty_Description = Не задан синоним у стандартного свойства 'Владелец' или 'Родитель' diff --git a/tests/com.e1c.v8codestyle.md.itests/src/com/e1c/v8codestyle/md/check/itests/MdObjectNameUnallowedLetterCheckTest.java b/tests/com.e1c.v8codestyle.md.itests/src/com/e1c/v8codestyle/md/check/itests/MdObjectNameUnallowedLetterCheckTest.java new file mode 100644 index 00000000..5841a2c9 --- /dev/null +++ b/tests/com.e1c.v8codestyle.md.itests/src/com/e1c/v8codestyle/md/check/itests/MdObjectNameUnallowedLetterCheckTest.java @@ -0,0 +1,106 @@ +/******************************************************************************* + * Copyright (C) 2022, 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.itests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +import com._1c.g5.v8.dt.core.platform.IDtProject; +import com._1c.g5.v8.dt.validation.marker.Marker; +import com.e1c.g5.v8.dt.testing.check.CheckTestBase; +import com.e1c.v8codestyle.md.check.MdObjectNameUnallowedLetterCheck; + +/** + * Tests for {@link MdObjectNameUnallowedLetterCheck} check + * + * @author OlgaBozhko + * + */ +public class MdObjectNameUnallowedLetterCheckTest + extends CheckTestBase +{ + private static final String CHECK_ID = "mdo-ru-name-unallowed-letter"; //$NON-NLS-1$ + private static final String PROJECT_NAME = "MdObjectNameUnallowedLetter"; + private static final String MESSAGE = + "In Russian locale, name, synonym or comment of metadata object contain the unallowed letter"; + + /** + * Test that md object name, synonym and comment do not contain unallowed letter "ё" (Ru locale) + * + * @throws Exception the exception + */ + @Test + public void testMdObjectNameNoUnallowedLetter() throws Exception + { + IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME); + assertNotNull(dtProject); + + long id = getTopObjectIdByFqn("Catalog.ТестовыйКаталог", dtProject); + Marker marker = getFirstMarker(CHECK_ID, id, dtProject); + assertNull(marker); + } + + /** + * Test that md object name contains unallowed letter "ё" (Ru locale) + * + * @throws Exception the exception + */ + @Test + public void testMdObjectNameHasUnallowedLetter() throws Exception + { + IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME); + assertNotNull(dtProject); + + long id = getTopObjectIdByFqn("Catalog.ТестовыйКаталог_ё_имя", dtProject); + Marker marker = getFirstMarker(CHECK_ID, id, dtProject); + assertNotNull(marker); + assertEquals(marker.getMessage(), MESSAGE); + } + + /** + * Test that md object synonym contains unallowed letter "ё" (Ru locale) + * + * @throws Exception the exception + */ + @Test + public void testMdObjectSynonymHasUnallowedLetter() throws Exception + { + IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME); + assertNotNull(dtProject); + + long id = getTopObjectIdByFqn("Catalog.ТестовыйКаталог_синоним", dtProject); + Marker marker = getFirstMarker(CHECK_ID, id, dtProject); + assertNotNull(marker); + assertEquals(marker.getMessage(), MESSAGE); + } + + /** + * Test that md object comment contains unallowed letter "ё" (Ru locale) + * + * @throws Exception the exception + */ + @Test + public void testMdObjectCommentHasUnallowedLetter() throws Exception + { + IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME); + assertNotNull(dtProject); + + long id = getTopObjectIdByFqn("Catalog.ТестовыйКаталог_комментарий", dtProject); + Marker marker = getFirstMarker(CHECK_ID, id, dtProject); + assertNotNull(marker); + assertEquals(marker.getMessage(), MESSAGE); + } +} diff --git a/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/.project b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/.project new file mode 100644 index 00000000..bafbcbcb --- /dev/null +++ b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/.project @@ -0,0 +1,18 @@ + + + MdObjectNameUnallowedLetter + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + + org.eclipse.xtext.ui.shared.xtextNature + com._1c.g5.v8.dt.core.V8ConfigurationNature + + diff --git a/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/.settings/org.eclipse.core.resources.prefs b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..99f26c02 --- /dev/null +++ b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/DT-INF/PROJECT.PMF b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/DT-INF/PROJECT.PMF new file mode 100644 index 00000000..6835f1cd --- /dev/null +++ b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/DT-INF/PROJECT.PMF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 +Runtime-Version: 8.3.19 diff --git a/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Catalogs/ТестовыйКаталог/ТестовыйКаталог.mdo b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Catalogs/ТестовыйКаталог/ТестовыйКаталог.mdo new file mode 100644 index 00000000..22085229 --- /dev/null +++ b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Catalogs/ТестовыйКаталог/ТестовыйКаталог.mdo @@ -0,0 +1,37 @@ + + + + + + + + + + ТестовыйКаталог + + ru + Тестовый каталог + + true + Catalog.ТестовыйКаталог.StandardAttribute.Code + Catalog.ТестовыйКаталог.StandardAttribute.Description + DontUse + Use + Managed + Use + + ru + 1 + + 2 + true + 9 + 25 + String + Variable + true + true + AsDescription + InDialog + BothWays + diff --git a/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Catalogs/ТестовыйКаталог_комментарий/ТестовыйКаталог_комментарий.mdo b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Catalogs/ТестовыйКаталог_комментарий/ТестовыйКаталог_комментарий.mdo new file mode 100644 index 00000000..e705aaa9 --- /dev/null +++ b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Catalogs/ТестовыйКаталог_комментарий/ТестовыйКаталог_комментарий.mdo @@ -0,0 +1,38 @@ + + + + + + + + + + ТестовыйКаталог_комментарий + + ru + Тестовый каталог комментарий + + ТестовыйКаталог_ё_комментарий + true + Catalog.ТестовыйКаталог_комментарий.StandardAttribute.Code + Catalog.ТестовыйКаталог_комментарий.StandardAttribute.Description + DontUse + Use + Managed + Use + + ru + 1 + + 2 + true + 9 + 25 + String + Variable + true + true + AsDescription + InDialog + BothWays + diff --git a/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Catalogs/ТестовыйКаталог_синоним/ТестовыйКаталог_синоним.mdo b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Catalogs/ТестовыйКаталог_синоним/ТестовыйКаталог_синоним.mdo new file mode 100644 index 00000000..35cfd220 --- /dev/null +++ b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Catalogs/ТестовыйКаталог_синоним/ТестовыйКаталог_синоним.mdo @@ -0,0 +1,37 @@ + + + + + + + + + + ТестовыйКаталог_синоним + + ru + Тестовый каталог ё синоним + + true + Catalog.ТестовыйКаталог_синоним.StandardAttribute.Code + Catalog.ТестовыйКаталог_синоним.StandardAttribute.Description + DontUse + Use + Managed + Use + + ru + 1 + + 2 + true + 9 + 25 + String + Variable + true + true + AsDescription + InDialog + BothWays + diff --git a/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Catalogs/ТестовыйКаталог_ё_имя/ТестовыйКаталог_ё_имя.mdo b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Catalogs/ТестовыйКаталог_ё_имя/ТестовыйКаталог_ё_имя.mdo new file mode 100644 index 00000000..321d328d --- /dev/null +++ b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Catalogs/ТестовыйКаталог_ё_имя/ТестовыйКаталог_ё_имя.mdo @@ -0,0 +1,37 @@ + + + + + + + + + + ТестовыйКаталог_ё_имя + + ru + Тестовый каталог + + true + Catalog.ТестовыйКаталог_ё_имя.StandardAttribute.Code + Catalog.ТестовыйКаталог_ё_имя.StandardAttribute.Description + DontUse + Use + Managed + Use + + ru + 1 + + 2 + true + 9 + 25 + String + Variable + true + true + AsDescription + InDialog + BothWays + diff --git a/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Configuration/CommandInterface.cmi b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Configuration/CommandInterface.cmi new file mode 100644 index 00000000..0cf6de8a --- /dev/null +++ b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Configuration/CommandInterface.cmi @@ -0,0 +1,2 @@ + + diff --git a/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Configuration/Configuration.mdo b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Configuration/Configuration.mdo new file mode 100644 index 00000000..aed4605e --- /dev/null +++ b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Configuration/Configuration.mdo @@ -0,0 +1,46 @@ + + + MdObjectNameUnallowedLetter + + ru + Md object name unallowed letter + + + + + + + + + 8.3.19 + ManagedApplication + PersonalComputer + Russian + + + true + + + OSBackup + true + + + Language.English + Managed + NotAutoFree + DontUse + DontUse + 8.3.19 + + English + + ru + English + + ru + + Catalog.ТестовыйКаталог + Catalog.ТестовыйКаталог_ё_имя + Catalog.ТестовыйКаталог_комментарий + Catalog.ТестовыйКаталог_синоним + diff --git a/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Configuration/MainSectionCommandInterface.cmi b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Configuration/MainSectionCommandInterface.cmi new file mode 100644 index 00000000..0cf6de8a --- /dev/null +++ b/tests/com.e1c.v8codestyle.md.itests/workspace/MdObjectNameUnallowedLetter/src/Configuration/MainSectionCommandInterface.cmi @@ -0,0 +1,2 @@ + +