Skip to content

Проверки корня конфигурации #1394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@
#### Метаданные

- Превышена максимальная длина числовых данных (31 знак). #82
- Не установлено свойство "Использовать управляемые формы в обычном приложении" для конфигурации. #67
- Неверно указана информация об авторских правах. Должно начинаться с "Copyright © ООО "1С-Софт"". #111
- Синоним конфигурации должен оканчиваться на номер редакции.подредакции. #287
- Не заполнен синоним конфигурации. #460
- В имени конфигурации запрещено использовать слова "редакция" или "подредакция". #463
- Неверно указан адрес информации о поставщике. Должен быть "http://www.1c.ru". #464
- Неверно указан адрес информации о конфигурации. Должен начинаться с "http://v8.1c.ru/". #465
- Неверно указан адрес каталога обновлений. Должен быть "http://downloads.v8.1c.ru/tmplts/". #466
- Не задан синоним объекта метаданных. #582
- Краткая информация отличается от синонима. #713
- Подробная информация отличается от синонима. #714
- Неверно указан поставщик. Должен быть "Фирма "1С"". #715
- Неверно установлен номер версии. Он не должен быть вида 0.0.0.0, N.0.0.0, N.0.N.0 или N.0.0.N. #109
- Неверно установлен номер версии. Правильный формат "РР.ПП.ЗЗ.СС". #712


#### Формы
Expand All @@ -25,6 +39,14 @@
#### Запросы


### Новые быстрые исправления (Quick-fix)

- Генрация синонима по имени для языка по умолчанию
- Установка версии конфигурации в значение по умолчанию или очистка неправильного значения
- Установка значения конфигурации "Использовать управляемые формы в обычном приложении"
- Краткая информация заполняется по синониму
- Подробная информация заполняется по синониму


### Прочие изменения

Expand Down
2 changes: 2 additions & 0 deletions bundles/com.e1c.v8codestyle.md/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Import-Package: com._1c.g5.v8.bm.core;version="[8.0.0,9.0.0)",
com.e1c.g5.v8.dt.check.components;version="[2.0.0,3.0.0)",
com.e1c.g5.v8.dt.check.context;version="[2.0.0,3.0.0)",
com.e1c.g5.v8.dt.check.ext;version="[1.0.0,2.0.0)",
com.e1c.g5.v8.dt.check.qfix;version="[2.0.0,3.0.0)",
com.e1c.g5.v8.dt.check.qfix.components;version="[1.0.0,2.0.0)",
com.e1c.g5.v8.dt.check.settings;version="[3.0.0,4.0.0)",
com.e1c.v8codestyle.check;version="[0.7.0,0.8.0)",
com.google.common.base;version="[30.1.0,31.0.0)",
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
66 changes: 66 additions & 0 deletions bundles/com.e1c.v8codestyle.md/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,58 @@
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.configuration.check.ConfigurationDataLock">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.configuration.check.ConfigurationBriefInformationCheck">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.configuration.check.ConfigurationCopyrightCheck">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.configuration.check.ConfigurationDetailedInformationCheck">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.configuration.check.ConfigurationInformationAddressCheck">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.configuration.check.ConfigurationNameCheck">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.configuration.check.ConfigurationSynonymCheck">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.configuration.check.ConfigurationUpdateCatalogAddressCheck">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.configuration.check.ConfigurationUseManagedFormsCheck">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.configuration.check.ConfigurationVendorCheck">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.configuration.check.ConfigurationVendorInformationAddressCheck">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.configuration.check.ConfigurationVersionCheck">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.check.MdObjectNameLength">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.check.MdObjectSynonymCheck">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.commonmodule.check.CommonModuleNameClient">
Expand Down Expand Up @@ -135,5 +183,23 @@
class="com.e1c.v8codestyle.md.functionoption.check.FunctionalOptionPrivilegedGetModeCheck">
</check>
</extension>
<extension
point="com.e1c.g5.v8.dt.check.fixes">
<fix
class="com.e1c.v8codestyle.md.configuration.qfix.ConfigurationUseManagedFormsFix">
</fix>
<fix
class="com.e1c.v8codestyle.md.configuration.qfix.ConfigurationVersionFix">
</fix>
<fix
class="com.e1c.v8codestyle.md.configuration.qfix.ConfigurationBriefInformationFix">
</fix>
<fix
class="com.e1c.v8codestyle.md.configuration.qfix.ConfigurationDetailedInformationFix">
</fix>
<fix
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.qfix.MdObjectSynonymDefaultLanguageFix">
</fix>
</extension>

</plugin>
Original file line number Diff line number Diff line change
@@ -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<String, String> uiString = (EMap<String, String>)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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading