1
0
mirror of https://github.com/1C-Company/v8-code-style.git synced 2025-01-20 21:18:18 +02:00

#84 Добавлена проверка длины ресурса регистра накопления или бухгалтерии (#1139)

This commit is contained in:
Timur Mukhamedishin 2022-09-17 01:20:52 +07:00 committed by GitHub
parent 1e4f144ddd
commit c8524548de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 431 additions and 2 deletions

View File

@ -10,6 +10,7 @@
#### Метаданные
- Превышена максимальная длина ресурса регистра накопления или бухгалтерии (25 знаков)
#### Формы

View File

@ -0,0 +1,11 @@
# Accumulation or accounting register resource precision
Accumulation or accounting register resource precision must be no more than 25
## Noncompliant Code Example
## Compliant Solution
## See

View File

@ -0,0 +1,11 @@
# Длина ресурса регистра накопления или бухгалтерии
Длина ресурса регистра накопления или бухгалтерии должна быть не больше 25 знаков
## Неправильно
## Правильно
## См.

View File

@ -62,6 +62,10 @@
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.md.check.MdScheduledJobPeriodicityCheck">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.md.check.RegisterResourcePrecisionCheck">
</check>
<check
category="com.e1c.v8codestyle.md"
class="com.e1c.v8codestyle.internal.md.ExecutableExtensionFactory:com.e1c.v8codestyle.md.check.CommonModuleNameServerCallCheck">

View File

@ -68,6 +68,9 @@ final class Messages
public static String UnsafePasswordStorageCheck_Avoid_storing_password_in_infobase;
public static String UnsafePasswordStorageCheck_Avoid_storing_password_in_infobase_description;
public static String UnsafePasswordStorageCheck_Avoid_storing_password_in_infobase_error;
public static String RegisterResourcePrecisionCheck_description;
public static String RegisterResourcePrecisionCheck_message;
public static String RegisterResourcePrecisionCheck_title;
public static String SubsystemSynonymTooLongCheck_description;
public static String SubsystemSynonymTooLongCheck_Exclude_languages_comma_separated;
public static String SubsystemSynonymTooLongCheck_Length_of_section_name_more_than_symbols_for_language;

View File

@ -0,0 +1,104 @@
/*******************************************************************************
* 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.mcore.McorePackage.Literals.TYPE_DESCRIPTION;
import static com._1c.g5.v8.dt.mcore.McorePackage.Literals.TYPE_DESCRIPTION__NUMBER_QUALIFIERS;
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.ACCOUNTING_REGISTER;
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.ACCUMULATION_REGISTER;
import java.text.MessageFormat;
import org.eclipse.core.runtime.IProgressMonitor;
import com._1c.g5.v8.dt.mcore.TypeDescription;
import com._1c.g5.v8.dt.metadata.mdclass.RegisterResource;
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 accounting or accumulation register resource precision that should be no more than 25.
*
* @author Timur Mukhamedishin
*/
public final class RegisterResourcePrecisionCheck
extends BasicCheck
{
private static final String CHECK_ID = "register-resource-precision"; //$NON-NLS-1$
public static final String MAX_PRECISION = "max-precision"; //$NON-NLS-1$
public static final String MAX_PRECISION_DEFAULT = "25"; //$NON-NLS-1$
@Override
public String getCheckId()
{
return CHECK_ID;
}
@Override
protected void configureCheck(CheckConfigurer builder)
{
builder.title(Messages.RegisterResourcePrecisionCheck_title)
.description(Messages.RegisterResourcePrecisionCheck_description)
.complexity(CheckComplexity.NORMAL)
.severity(IssueSeverity.MINOR)
.issueType(IssueType.PORTABILITY)
.extension(new StandardCheckExtension(getCheckId(), CorePlugin.PLUGIN_ID))
.parameter(MAX_PRECISION, Integer.class, MAX_PRECISION_DEFAULT,
Messages.RegisterResourcePrecisionCheck_message);
builder.topObject(ACCUMULATION_REGISTER)
.checkTop()
.containment(TYPE_DESCRIPTION)
.features(TYPE_DESCRIPTION__NUMBER_QUALIFIERS);
builder.topObject(ACCOUNTING_REGISTER)
.checkTop()
.containment(TYPE_DESCRIPTION)
.features(TYPE_DESCRIPTION__NUMBER_QUALIFIERS);
}
@Override
protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters,
IProgressMonitor monitor)
{
if (!(object instanceof TypeDescription))
{
return;
}
TypeDescription td = (TypeDescription)object;
if (!(td.eContainer() instanceof RegisterResource))
{
return;
}
int maxPrecision = parameters.getInt(MAX_PRECISION);
int precision = td.getNumberQualifiers().getPrecision();
if (precision > maxPrecision)
{
RegisterResource resource = (RegisterResource)(td.eContainer());
resultAceptor.addIssue(
MessageFormat.format(Messages.RegisterResourcePrecisionCheck_message, resource.getName(), maxPrecision),
td);
}
}
}

View File

@ -97,12 +97,18 @@ UnsafePasswordStorageCheck_Avoid_storing_password_in_infobase_description=To min
UnsafePasswordStorageCheck_Avoid_storing_password_in_infobase_error=Avoid storing passwords in the infobase
RegisterResourcePrecisionCheck_description = Accumulation or accounting register resource precision is more than 25
RegisterResourcePrecisionCheck_message = Accumulation or accounting register resource "{0}" precision is more than {1}
RegisterResourcePrecisionCheck_title = Accumulation or accounting register resource precision is more than 25
SubsystemSynonymTooLongCheck_Exclude_languages_comma_separated = Exclude languages (codes, comma-separated)
SubsystemSynonymTooLongCheck_Length_of_section_name_more_than_symbols_for_language = Length of section synonym "{0}" more than {1} symbols for language {2}
SubsystemSynonymTooLongCheck_Maximum_section_name_length = Maximum section name length
SubsystemSynonymTooLongCheck_description = Section name is more then 35 characters long
SubsystemSynonymTooLongCheck_description = Section name is more than 35 characters long
SubsystemSynonymTooLongCheck_title = Section name is more then 35 characters long
SubsystemSynonymTooLongCheck_title = Section name is more than 35 characters long

View File

@ -92,6 +92,12 @@ MdScheduledJobPeriodicityCheck_description = Периодичность выпо
MdScheduledJobPeriodicityCheck_title = Периодичность выполнения регламентного задания меньше {0}сек
RegisterResourcePrecisionCheck_description = Превышена максимальная длина ресурса регистра накопления или бухгалтерии (25 знаков)
RegisterResourcePrecisionCheck_message = Длина ресурса регистра "{0}" превышает {1}
RegisterResourcePrecisionCheck_title = Превышена максимальная длина ресурса регистра накопления или бухгалтерии (25 знаков)
SubsystemSynonymTooLongCheck_Exclude_languages_comma_separated = Исключить языки (коды, разделенных запятыми)
SubsystemSynonymTooLongCheck_Length_of_section_name_more_than_symbols_for_language = Длина синонима раздела "{0}" превышает {1} символов для языка {2}

View File

@ -0,0 +1,74 @@
/*******************************************************************************
* 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.itests;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import com._1c.g5.v8.bm.core.IBmObject;
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;
/**
* Tests for {@link RegisterResourcePrecision} check
*
* @author Timur Mukhamedishin
*
*/
public class RegisterResourcePrecisionTest
extends CheckTestBase
{
private static final String CHECK_ID = "register-resource-precision"; //$NON-NLS-1$
private static final String PROJECT_NAME = "RegisterResourcePrecision";
/**
* Test that accounting register resource precision longer than maximal length.
*
* @throws Exception the exception
*/
@Test
public void testAccountingRegisterResourcePrecision() throws Exception
{
IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME);
assertNotNull(dtProject);
IBmObject object =
getTopObjectByFqn("AccountingRegister.AccountingRegisterTest", dtProject);
assertNotNull(object);
Marker marker = getFirstNestedMarker(CHECK_ID, object.bmGetId(), dtProject);
assertNotNull(marker);
}
/**
* Test that accumulation register resource precision longer than maximal length.
*
* @throws Exception the exception
*/
@Test
public void testAccumulationRegisterResourcePrecision() throws Exception
{
IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME);
assertNotNull(dtProject);
IBmObject object = getTopObjectByFqn("AccumulationRegister.AccumulationRegisterTest", dtProject);
assertNotNull(object);
Marker marker = getFirstNestedMarker(CHECK_ID, object.bmGetId(), dtProject);
assertNotNull(marker);
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>RegisterResourcePrecision</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>com._1c.g5.v8.dt.core.V8ConfigurationNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,2 @@
Manifest-Version: 1.0
Runtime-Version: 8.3.19

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:AccountingRegister xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:core="http://g5.1c.ru/v8/dt/mcore" xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="f06a5082-f22b-4f1e-9bd0-d3821a995fa7">
<producedTypes>
<selectionType typeId="80ab005e-65d7-443d-b942-4a3b994760b2" valueTypeId="326e3f70-2c5b-404c-ba18-4fe45c28e364"/>
<listType typeId="3992043a-b176-4de1-9782-6e29d498f75c" valueTypeId="3e9c51aa-611b-4d05-a9bc-0a416f65e37a"/>
<managerType typeId="fee9bfb2-ca64-46af-a841-435843d566ac" valueTypeId="341a0d7c-9ed8-4323-8c0d-5437b93ceca5"/>
<recordSetType typeId="74a60a43-37b2-42bd-83be-749cd2a11b4a" valueTypeId="95af0b8e-5c1f-4fab-aa68-ce978ff90039"/>
<recordKeyType typeId="280731f4-b221-4c34-a86b-556229bcbf14" valueTypeId="f9ed97b9-3ecf-465d-8d44-05f8602268da"/>
<recordType typeId="b98dba37-a5f6-4203-93c6-21c66f4bb6ab" valueTypeId="a138593d-7d72-4388-96c5-740a4b7d4413"/>
<extDimensionsType typeId="894b1311-fff0-468e-90a9-ca807c46b0ba" valueTypeId="581f2fbb-ff59-4044-af8b-60a6f6875375"/>
</producedTypes>
<name>AccountingRegisterTest</name>
<synonym>
<key>en</key>
<value>Accounting register test</value>
</synonym>
<useStandardCommands>true</useStandardCommands>
<dataLockControlMode>Managed</dataLockControlMode>
<enableTotalsSplitting>true</enableTotalsSplitting>
<resources uuid="420c3339-cf1a-47a7-83da-ec5e11cce703">
<name>CorrectResource</name>
<synonym>
<key>en</key>
<value>Correct resource</value>
</synonym>
<type>
<types>Number</types>
<numberQualifiers>
<precision>10</precision>
</numberQualifiers>
</type>
<minValue xsi:type="core:UndefinedValue"/>
<maxValue xsi:type="core:UndefinedValue"/>
<fullTextSearch>Use</fullTextSearch>
<balance>true</balance>
</resources>
<resources uuid="dbafc4fe-1a6b-4b08-9ac6-b0ff7b152ce8">
<name>WrongResource</name>
<synonym>
<key>en</key>
<value>Wrong resource</value>
</synonym>
<type>
<types>Number</types>
<numberQualifiers>
<precision>50</precision>
</numberQualifiers>
</type>
<minValue xsi:type="core:UndefinedValue"/>
<maxValue xsi:type="core:UndefinedValue"/>
<fullTextSearch>Use</fullTextSearch>
<balance>true</balance>
</resources>
</mdclass:AccountingRegister>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:AccumulationRegister xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:core="http://g5.1c.ru/v8/dt/mcore" xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="0fc0a0f0-3449-4800-b5dc-5a12771ec1a3">
<producedTypes>
<selectionType typeId="b8c1dd8d-185a-4f07-977a-eddf952a5955" valueTypeId="b9b0847e-9da9-41ef-a918-f4af63c65e97"/>
<listType typeId="5d633f28-2b90-4f48-9f81-6e7a59a7933c" valueTypeId="811058e1-0b85-471d-9f6f-e8597da3ae38"/>
<managerType typeId="c4fee4bc-c8f3-4f7d-a2af-c45c5705b322" valueTypeId="25b4dfcd-89a7-485c-b5b8-d56361ce7a23"/>
<recordSetType typeId="7228e73e-187a-498f-a37d-329028f17e3e" valueTypeId="933dadfc-3947-42a9-a161-39ef45325a51"/>
<recordKeyType typeId="47e97b8a-f2ef-48dc-a90e-7773ba35c1a1" valueTypeId="852fb452-1b82-4288-9038-060c7c61bdc4"/>
<recordType typeId="c103e40a-5f32-40db-932c-06ceb76f1326" valueTypeId="6f577159-2cb2-4bc9-b91c-e93c97a13190"/>
</producedTypes>
<name>AccumulationRegisterTest</name>
<synonym>
<key>en</key>
<value>Accumulation register test</value>
</synonym>
<useStandardCommands>true</useStandardCommands>
<dataLockControlMode>Managed</dataLockControlMode>
<enableTotalsSplitting>true</enableTotalsSplitting>
<resources uuid="c75d6720-29b9-493c-8de5-05cb22d29d1c">
<name>CorrectResource</name>
<synonym>
<key>en</key>
<value>Correct resource</value>
</synonym>
<type>
<types>Number</types>
<numberQualifiers>
<precision>10</precision>
</numberQualifiers>
</type>
<minValue xsi:type="core:UndefinedValue"/>
<maxValue xsi:type="core:UndefinedValue"/>
<fullTextSearch>Use</fullTextSearch>
</resources>
<resources uuid="505b898f-30bc-4c3f-b33d-3e7e3128cd3c">
<name>WrongResource</name>
<synonym>
<key>en</key>
<value>Wrong resource</value>
</synonym>
<type>
<types>Number</types>
<numberQualifiers>
<precision>50</precision>
</numberQualifiers>
</type>
<minValue xsi:type="core:UndefinedValue"/>
<maxValue xsi:type="core:UndefinedValue"/>
<fullTextSearch>Use</fullTextSearch>
</resources>
</mdclass:AccumulationRegister>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:Configuration xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="20a84f2b-cefe-4539-878f-0f7ed39f0672">
<name>RegisterResourcePrecision</name>
<synonym>
<key>en</key>
<value>Register resource precision</value>
</synonym>
<containedObjects classId="9cd510cd-abfc-11d4-9434-004095e12fc7" objectId="10f19cab-e7bd-4f2c-a575-908cbcb28af7"/>
<containedObjects classId="9fcd25a0-4822-11d4-9414-008048da11f9" objectId="5bbfdbba-5e09-4ade-9aff-56f49a4ed62f"/>
<containedObjects classId="e3687481-0a87-462c-a166-9f34594f9bba" objectId="3b15f715-c7ed-408a-a853-72d3fe7fa380"/>
<containedObjects classId="9de14907-ec23-4a07-96f0-85521cb6b53b" objectId="80f97575-17c0-4a54-8b72-f23c4c14c70a"/>
<containedObjects classId="51f2d5d8-ea4d-4064-8892-82951750031e" objectId="f0575f92-54f8-4dbf-9aa8-ccf984f4a37f"/>
<containedObjects classId="e68182ea-4237-4383-967f-90c1e3370bc7" objectId="aae6bb3b-6d1b-430e-8733-7a6dca4d6d54"/>
<containedObjects classId="fb282519-d103-4dd3-bc12-cb271d631dfc" objectId="addba4b7-5dd8-4413-8bc0-203ca37f6ecd"/>
<configurationExtensionCompatibilityMode>8.3.19</configurationExtensionCompatibilityMode>
<defaultRunMode>ManagedApplication</defaultRunMode>
<usePurposes>PersonalComputer</usePurposes>
<usedMobileApplicationFunctionalities>
<functionality>
<use>true</use>
</functionality>
<functionality>
<functionality>OSBackup</functionality>
<use>true</use>
</functionality>
</usedMobileApplicationFunctionalities>
<defaultLanguage>Language.English</defaultLanguage>
<dataLockControlMode>Managed</dataLockControlMode>
<objectAutonumerationMode>NotAutoFree</objectAutonumerationMode>
<modalityUseMode>DontUse</modalityUseMode>
<synchronousPlatformExtensionAndAddInCallUseMode>DontUse</synchronousPlatformExtensionAndAddInCallUseMode>
<compatibilityMode>8.3.19</compatibilityMode>
<languages uuid="7ccd8163-8b83-42d1-94d7-ee638da6d2f1">
<name>English</name>
<synonym>
<key>en</key>
<value>English</value>
</synonym>
<languageCode>en</languageCode>
</languages>
<documents>Document.DocumentTest</documents>
<accumulationRegisters>AccumulationRegister.AccumulationRegisterTest</accumulationRegisters>
<accountingRegisters>AccountingRegister.AccountingRegisterTest</accountingRegisters>
</mdclass:Configuration>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:Document xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="fddd3e1c-0dee-4de8-9792-b4f845c7563f">
<producedTypes>
<objectType typeId="a4f26721-36fc-425d-b792-7fad96669b06" valueTypeId="3d9452e5-5228-4e0b-a1a6-39e95aca347e"/>
<refType typeId="fc945ade-1cf6-4ecf-8294-a1750a8890fc" valueTypeId="bd30a3c9-2455-48fd-b4bb-70f5881b325f"/>
<selectionType typeId="9afb660a-b7b5-4259-9dfe-b4f679299533" valueTypeId="c143e57c-18c9-47d8-88f6-74da9db07e3d"/>
<listType typeId="0aa1e71b-8588-4984-bc84-bf83d67f7a6e" valueTypeId="736d5a42-1c90-4f97-a4ed-60f96b770b8f"/>
<managerType typeId="73795ce9-87a9-49c6-82bb-a512f8bc638f" valueTypeId="86126dea-18bf-4201-b7db-1e4ac219bb97"/>
</producedTypes>
<name>DocumentTest</name>
<synonym>
<key>en</key>
<value>Document test</value>
</synonym>
<useStandardCommands>true</useStandardCommands>
<inputByString>Document.DocumentTest.StandardAttribute.Number</inputByString>
<fullTextSearchOnInputByString>DontUse</fullTextSearchOnInputByString>
<createOnInput>Use</createOnInput>
<dataLockControlMode>Managed</dataLockControlMode>
<fullTextSearch>Use</fullTextSearch>
<objectPresentation>
<key>en</key>
<value>123</value>
</objectPresentation>
<numberType>String</numberType>
<numberLength>9</numberLength>
<numberAllowedLength>Variable</numberAllowedLength>
<checkUnique>true</checkUnique>
<autonumbering>true</autonumbering>
<registerRecords>AccumulationRegister.AccumulationRegisterTest</registerRecords>
<registerRecords>AccountingRegister.AccountingRegisterTest</registerRecords>
<postInPrivilegedMode>true</postInPrivilegedMode>
<unpostInPrivilegedMode>true</unpostInPrivilegedMode>
</mdclass:Document>