1
0
mirror of https://github.com/1C-Company/v8-code-style.git synced 2025-02-02 06:03:36 +02:00

Merge pull request #1096 from 1C-Company/bugfix/1087-doc-comment-param-section

Проверка: doc-comment-parameter-section не находит ошибку #1087
This commit is contained in:
Dmitriy Marmyshev 2022-09-16 15:02:20 +03:00 committed by GitHub
commit 11f2360b6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 417 additions and 29 deletions

View File

@ -56,7 +56,7 @@
- Структура модуля. Добавлена проверка соответсвия состава областей верхнего модуля стандарту, их порядка и наличия дублей.
- Структура модуля. Проверка что код инициализации расположен в области инициализации.
- Структура модуля. Область объявления переменных.
- Из проверка doc-comment-parameter-section выделена проверка doc-comment-redundant-parameter-section
#### Запросы
@ -103,6 +103,7 @@
- Ложное срабатывание проверки: ql-constants-in-binary-operation #1142
- Не понятно в какой бинарной операции ошибка ql-constants-in-binary-operation #1143
- Возникает NPE при работе проверки form-list-ref-user-visibility-enabled #1146
- Проверка: doc-comment-parameter-section не находит ошибку #1087
## 0.2.0

View File

@ -0,0 +1,27 @@
# Documentation comment parameter section is redundant
Documentation comment for method without parameters should not have parameter section and should be removed.
## Noncompliant Code Example
```bsl
// Parameters:
// Parameters - Method should not have parameter section
Procedure NonComplaint()
// empty
EndProcedure
```
## Compliant Solution
```bsl
// Method without parameters should not have such section
Procedure Complaint()
// empty
EndProcedure
```
## See

View File

@ -0,0 +1,28 @@
# Секция параметров документирующего комментария избыточная
Документирующий комментарий для метода без параметров не должен иметь секции параметров, и она должна быть удалена.
## Неправильно
```bsl
// Параметры:
// Параметры - Метод не должен иметь секцию параметров
Процедура Неправильно()
// пусто
КонецПрцоедуры
```
## Правильно
```bsl
// Метод без параметров не должен иметь такую секцию
Процедура Правильно()
// пусто
КонецПрцоедуры
```
## См.

View File

@ -176,6 +176,10 @@
category="com.e1c.v8codestyle.bsl.comment"
class="com.e1c.v8codestyle.internal.bsl.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.comment.check.ParametersSectionCheck">
</check>
<check
category="com.e1c.v8codestyle.bsl.comment"
class="com.e1c.v8codestyle.internal.bsl.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.comment.check.RedundantParametersSectionCheck">
</check>
<check
category="com.e1c.v8codestyle.bsl.comment"
class="com.e1c.v8codestyle.internal.bsl.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.comment.check.ProcedureReturnSectionCheck">

View File

@ -57,7 +57,10 @@ final class Messages
public static String ParametersSectionCheck_Check_only_export_method_parameter_section;
public static String ParametersSectionCheck_description;
public static String ParametersSectionCheck_Parameter_definition_missed_for__N;
public static String ParametersSectionCheck_Remove_useless_parameter_section;
public static String ParametersSectionCheck_Require_parameter_section_only_for_Export_methods;
public static String RedundantParametersSectionCheck_description;
public static String RedundantParametersSectionCheck_Remove_useless_parameter_section;
public static String RedundantParametersSectionCheck_title;
public static String ParametersSectionCheck_title;
public static String ProcedureReturnSectionCheck_description;
public static String ProcedureReturnSectionCheck_Procedure_should_has_no_return_section;

View File

@ -12,24 +12,36 @@
*******************************************************************************/
package com.e1c.v8codestyle.bsl.comment.check;
import static com._1c.g5.v8.dt.mcore.McorePackage.Literals.NAMED_ELEMENT__NAME;
import java.text.MessageFormat;
import java.util.Set;
import java.util.TreeSet;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.xtext.scoping.IScopeProvider;
import com._1c.g5.v8.dt.bsl.comment.DocumentationCommentProperties;
import com._1c.g5.v8.dt.bsl.common.IBslPreferences;
import com._1c.g5.v8.dt.bsl.documentation.comment.BslCommentUtils;
import com._1c.g5.v8.dt.bsl.documentation.comment.BslDocumentationComment;
import com._1c.g5.v8.dt.bsl.documentation.comment.BslDocumentationComment.ParametersSection;
import com._1c.g5.v8.dt.bsl.documentation.comment.BslMultiLineCommentDocumentationProvider;
import com._1c.g5.v8.dt.bsl.documentation.comment.IDescriptionPart;
import com._1c.g5.v8.dt.bsl.documentation.comment.LinkPart;
import com._1c.g5.v8.dt.bsl.documentation.comment.TypeSection.FieldDefinition;
import com._1c.g5.v8.dt.bsl.model.FormalParam;
import com._1c.g5.v8.dt.bsl.model.Method;
import com._1c.g5.v8.dt.common.StringUtils;
import com.e1c.g5.v8.dt.bsl.check.DocumentationCommentBasicDelegateCheck;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com.e1c.g5.v8.dt.check.CheckComplexity;
import com.e1c.g5.v8.dt.check.ICheckParameters;
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.bsl.BslPlugin;
import com.google.inject.Inject;
/**
* Validates that each of parameters specified in documenting comments.
@ -39,13 +51,34 @@ import com.e1c.v8codestyle.internal.bsl.BslPlugin;
*
*/
public class ParametersSectionCheck
extends DocumentationCommentBasicDelegateCheck
extends AbstractDocCommentTypeCheck
{
private static final String CHECK_ID = "doc-comment-parameter-section"; //$NON-NLS-1$
private static final String PARAMETER_CHECK_ONLY_EXPORT = "checkOnlyExport"; //$NON-NLS-1$
private static final String PARAMETER_PARMA_SECT_FOR_EXPORT = "requireParameterSectionOnlyForExport"; //$NON-NLS-1$
private final IResourceLookup resourceLookup;
private final IBslPreferences bslPreferences;
private final IScopeProvider scopeProvider;
private final BslMultiLineCommentDocumentationProvider commentProvider;
@Inject
public ParametersSectionCheck(IResourceLookup resourceLookup, IBslPreferences bslPreferences,
IScopeProvider scopeProvider, BslMultiLineCommentDocumentationProvider commentProvider)
{
super();
this.resourceLookup = resourceLookup;
this.bslPreferences = bslPreferences;
this.scopeProvider = scopeProvider;
this.commentProvider = commentProvider;
}
@Override
public String getCheckId()
{
@ -61,48 +94,123 @@ public class ParametersSectionCheck
.severity(IssueSeverity.MINOR)
.issueType(IssueType.CODE_STYLE)
.extension(new StandardCheckExtension(getCheckId(), BslPlugin.PLUGIN_ID))
.delegate(ParametersSection.class);
builder.parameter(PARAMETER_CHECK_ONLY_EXPORT, Boolean.class, Boolean.FALSE.toString(),
Messages.ParametersSectionCheck_Check_only_export_method_parameter_section);
.delegate(ParametersSection.class, BslDocumentationComment.class);
builder
.parameter(PARAMETER_CHECK_ONLY_EXPORT, Boolean.class, Boolean.FALSE.toString(),
Messages.ParametersSectionCheck_Check_only_export_method_parameter_section)
.parameter(PARAMETER_PARMA_SECT_FOR_EXPORT, Boolean.class, Boolean.TRUE.toString(),
Messages.ParametersSectionCheck_Require_parameter_section_only_for_Export_methods);
}
@Override
protected void checkDocumentationCommentObject(IDescriptionPart object, BslDocumentationComment root,
DocumentationCommentResultAcceptor resultAceptor, ICheckParameters parameters, IProgressMonitor monitor)
{
ParametersSection parameterSection = (ParametersSection)object;
if (root.getMethod().getFormalParams().isEmpty())
{
// TODO Extract to new check that parameter section is empty and useless
resultAceptor.addIssue(Messages.ParametersSectionCheck_Remove_useless_parameter_section,
parameterSection.getHeaderKeywordLength());
return;
}
if (object instanceof BslDocumentationComment)
{
check((BslDocumentationComment)object, resultAceptor, parameters, monitor);
}
else if (object instanceof ParametersSection)
{
check((ParametersSection)object, root, resultAceptor, parameters, monitor);
}
}
private void check(ParametersSection object, BslDocumentationComment root,
DocumentationCommentResultAcceptor resultAceptor, ICheckParameters parameters, IProgressMonitor monitor)
{
if (!root.getMethod().isExport() && parameters.getBoolean(PARAMETER_CHECK_ONLY_EXPORT))
{
return;
}
ParametersSection parameterSection = object;
Set<String> parameterNames = getAbsentParameterDefinition(root.getMethod(), parameterSection);
addIssues(root.getMethod(), parameterNames, resultAceptor);
}
private void check(BslDocumentationComment object, DocumentationCommentResultAcceptor resultAceptor,
ICheckParameters parameters, IProgressMonitor monitor)
{
if (object.getParametersSection() != null
|| (!object.getMethod().isExport() && parameters.getBoolean(PARAMETER_PARMA_SECT_FOR_EXPORT)))
{
return;
}
BslDocumentationComment docComment = null;
if (isInheritedFromLink(object))
{
LinkPart linkPart = getSingleLinkPart(object.getDescription());
IProject project = resourceLookup.getProject(object.getModule());
DocumentationCommentProperties props = bslPreferences.getDocumentCommentProperties(project);
docComment = BslCommentUtils.getLinkPartCommentContent(linkPart, scopeProvider, commentProvider,
props.oldCommentFormat(), object.getMethod());
}
if (docComment == null)
{
docComment = object;
}
Set<String> parameterNames =
getAbsentParameterDefinition(object.getMethod(), docComment.getParametersSection());
addIssues(object.getMethod(), parameterNames, resultAceptor);
}
private Set<String> getAbsentParameterDefinition(Method method, ParametersSection parameterSection)
{
Set<String> parameterNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
root.getMethod().getFormalParams().forEach(p -> {
method.getFormalParams().forEach(p -> {
if (p != null && StringUtils.isNotBlank(p.getName()))
{
parameterNames.add(p.getName());
}
});
if (parameterSection == null)
{
return parameterNames;
}
for (FieldDefinition parameterDefinition : parameterSection.getParameterDefinitions())
{
parameterNames.remove(parameterDefinition.getName());
}
if (!parameterNames.isEmpty())
return parameterNames;
}
private void addIssues(Method method, Set<String> parameterNames, DocumentationCommentResultAcceptor resultAceptor)
{
if (parameterNames.isEmpty())
{
String message = MessageFormat.format(Messages.ParametersSectionCheck_Parameter_definition_missed_for__N,
String.join(", ", parameterNames)); //$NON-NLS-1$
resultAceptor.addIssue(message, parameterSection.getHeaderKeywordLength());
return;
}
for (FormalParam param : method.getFormalParams())
{
if (parameterNames.contains(param.getName()))
{
String message = MessageFormat
.format(Messages.ParametersSectionCheck_Parameter_definition_missed_for__N, param.getName());
resultAceptor.addIssue(message, param, NAMED_ELEMENT__NAME);
parameterNames.remove(param.getName());
}
}
}
private boolean isInheritedFromLink(BslDocumentationComment docComment)
{
return docComment.getReturnSection() == null && docComment.getParametersSection() == null
&& getSingleLinkPart(docComment.getDescription()) != null;
}
}

View File

@ -0,0 +1,70 @@
/*******************************************************************************
* 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.bsl.comment.check;
import org.eclipse.core.runtime.IProgressMonitor;
import com._1c.g5.v8.dt.bsl.documentation.comment.BslDocumentationComment;
import com._1c.g5.v8.dt.bsl.documentation.comment.BslDocumentationComment.ParametersSection;
import com._1c.g5.v8.dt.bsl.documentation.comment.IDescriptionPart;
import com.e1c.g5.v8.dt.bsl.check.DocumentationCommentBasicDelegateCheck;
import com.e1c.g5.v8.dt.check.CheckComplexity;
import com.e1c.g5.v8.dt.check.ICheckParameters;
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.bsl.BslPlugin;
/**
* Validates that method without parameters should not have parameter section.
*
* @author Dmitriy Marmyshev
*
*/
public class RedundantParametersSectionCheck
extends DocumentationCommentBasicDelegateCheck
{
private static final String CHECK_ID = "doc-comment-redundant-parameter-section"; //$NON-NLS-1$
@Override
public String getCheckId()
{
return CHECK_ID;
}
@Override
protected void configureCheck(CheckConfigurer builder)
{
builder.title(Messages.RedundantParametersSectionCheck_title)
.description(Messages.RedundantParametersSectionCheck_description)
.complexity(CheckComplexity.NORMAL)
.severity(IssueSeverity.MINOR)
.issueType(IssueType.CODE_STYLE)
.extension(new StandardCheckExtension(getCheckId(), BslPlugin.PLUGIN_ID))
.delegate(ParametersSection.class);
}
@Override
protected void checkDocumentationCommentObject(IDescriptionPart object, BslDocumentationComment root,
DocumentationCommentResultAcceptor resultAceptor, ICheckParameters parameters, IProgressMonitor monitor)
{
ParametersSection parameterSection = (ParametersSection)object;
if (root.getMethod().getFormalParams().isEmpty())
{
resultAceptor.addIssue(Messages.RedundantParametersSectionCheck_Remove_useless_parameter_section,
parameterSection.getHeaderKeywordLength());
}
}
}

View File

@ -80,7 +80,7 @@ ParametersSectionCheck_Check_only_export_method_parameter_section = Check only e
ParametersSectionCheck_Parameter_definition_missed_for__N = Parameter definition missed for: {0}
ParametersSectionCheck_Remove_useless_parameter_section = Remove useless parameter section
ParametersSectionCheck_Require_parameter_section_only_for_Export_methods = Require parameter section only for export methods
ParametersSectionCheck_description = Documentation comment parameter section missed parameter definition
@ -92,6 +92,12 @@ ProcedureReturnSectionCheck_description = Documentation comment has return secti
ProcedureReturnSectionCheck_title = Documentation comment has return section for procedure
RedundantParametersSectionCheck_Remove_useless_parameter_section = Remove redundant parameter section
RedundantParametersSectionCheck_description = Documentation comment for method without parameters should not have parameter section and should be removed
RedundantParametersSectionCheck_title = Documentation comment parameter section is redundant
RefLinkPartCheck_Allow_See_in_description = Allow 'See something' in description
RefLinkPartCheck_Link_referenced_to_unexisting_object = Link referenced to unexisting object

View File

@ -80,7 +80,7 @@ ParametersSectionCheck_Check_only_export_method_parameter_section = Провер
ParametersSectionCheck_Parameter_definition_missed_for__N = Пропущено определение параметра для: {0}
ParametersSectionCheck_Remove_useless_parameter_section = Удалите бесполезную секцию параметров
ParametersSectionCheck_Require_parameter_section_only_for_Export_methods = Требовать наличия секции параметров только для экспортных методов
ParametersSectionCheck_description = В секции параметров документирующего комментария пропущено определение параметра
@ -92,6 +92,12 @@ ProcedureReturnSectionCheck_description = Документирующий ком
ProcedureReturnSectionCheck_title = Документирующий комментарий содежрит секцию возвращаемого значения для процедуры
RedundantParametersSectionCheck_Remove_useless_parameter_section = Удалите избыточную секцию параметров
RedundantParametersSectionCheck_description = Документирующий комментарий для метода без параметров не должен иметь секции параметров, и она должна быть удалена.
RedundantParametersSectionCheck_title = Секция параметров документирующего комментария избыточная
RefLinkPartCheck_Allow_See_in_description = Разрешить 'См. сюда' в элементе описания
RefLinkPartCheck_Link_referenced_to_unexisting_object = Ссылка на несуществующий объект

View File

@ -7,9 +7,13 @@ Procedure NonComplaint(Parameters, SecondParameter) Export
// empty
EndProcedure
// Parameters:
// Parameters - Method should not have parameter section
Procedure NonComplaint2() Export
// See Complaint
Procedure NonComplaint2(Parameters, SecondParameter) Export
// empty
EndProcedure
// No parameter section
Procedure NonComplaint3(Parameters) Export
// empty
EndProcedure
@ -24,3 +28,9 @@ EndProcedure
Procedure Complaint2(Parameters, SecondParameter)
// empty
EndProcedure
// local methods may not contains parameters secrion
Procedure Complaint3(Parameters)
// empty
EndProcedure

View File

@ -0,0 +1,17 @@
// Parameters:
// Parameters - Method should not have parameter section
Procedure NonComplaint() Export
// empty
EndProcedure
// without parameter setion
Procedure Complaint() Export
// empty
EndProcedure
// Parameters:
// Parameters - local methods may not contains all parameters
Procedure Complaint2(Parameters, SecondParameter)
// empty
EndProcedure

View File

@ -40,6 +40,8 @@ public class ParametersSectionCheckTest
private static final String PARAMETER_CHECK_ONLY_EXPORT = "checkOnlyExport"; //$NON-NLS-1$
private static final String PARAMETER_PARMA_SECT_FOR_EXPORT = "requireParameterSectionOnlyForExport"; //$NON-NLS-1$
public ParametersSectionCheckTest()
{
super(ParametersSectionCheck.class);
@ -58,35 +60,86 @@ public class ParametersSectionCheckTest
ICheckSettings settings = checkRepository.getSettings(cuid, project);
ICheckParameterSettings parameter = settings.getParameters().get(PARAMETER_CHECK_ONLY_EXPORT);
parameter.setValue(Boolean.TRUE.toString());
parameter = settings.getParameters().get(PARAMETER_PARMA_SECT_FOR_EXPORT);
parameter.setValue(Boolean.TRUE.toString());
checkRepository.applyChanges(Collections.singleton(settings), project);
updateModule(FOLDER_RESOURCE + "doc-comment-parameter-section.bsl");
List<Marker> markers = getModuleMarkers();
assertEquals(2, markers.size());
assertEquals(3, markers.size());
Marker marker = markers.get(0);
assertEquals("4", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("6", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
marker = markers.get(1);
assertEquals("10", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("11", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
marker = markers.get(2);
assertEquals("16", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
}
/**
* Test the documentation comment parameter section should exists in documentation comment not only for
* export methods, but for non-export (private) methods
*
* @throws Exception the exception
*/
@Test
public void testParamSectionNotOnlyForExportMethodShouldCheck() throws Exception
{
IProject project = getProject().getWorkspaceProject();
CheckUid cuid = new CheckUid(getCheckId(), BslPlugin.PLUGIN_ID);
ICheckSettings settings = checkRepository.getSettings(cuid, project);
ICheckParameterSettings parameter = settings.getParameters().get(PARAMETER_CHECK_ONLY_EXPORT);
parameter.setValue(Boolean.FALSE.toString());
parameter = settings.getParameters().get(PARAMETER_PARMA_SECT_FOR_EXPORT);
parameter.setValue(Boolean.FALSE.toString());
checkRepository.applyChanges(Collections.singleton(settings), project);
updateModule(FOLDER_RESOURCE + "doc-comment-parameter-section.bsl");
List<Marker> markers = getModuleMarkers();
assertEquals(5, markers.size());
Marker marker = markers.get(0);
assertEquals("6", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
marker = markers.get(1);
assertEquals("11", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
marker = markers.get(2);
assertEquals("16", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
marker = markers.get(3);
assertEquals("28", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
marker = markers.get(4);
assertEquals("33", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
}
/**
* Test the documentation comment parameter section should contains all parameters of all methods.
* Only export method should contains parameter section if it has parameters.
* This is default settings.
*
* @throws Exception the exception
*/
@Test
public void testAllMethodParametersShouldCheck() throws Exception
{
IProject project = getProject().getWorkspaceProject();
CheckUid cuid = new CheckUid(getCheckId(), BslPlugin.PLUGIN_ID);
ICheckSettings settings = checkRepository.getSettings(cuid, project);
ICheckParameterSettings parameter = settings.getParameters().get(PARAMETER_CHECK_ONLY_EXPORT);
parameter.setValue(Boolean.FALSE.toString());
parameter = settings.getParameters().get(PARAMETER_PARMA_SECT_FOR_EXPORT);
parameter.setValue(Boolean.TRUE.toString());
checkRepository.applyChanges(Collections.singleton(settings), project);
updateModule(FOLDER_RESOURCE + "doc-comment-parameter-section.bsl");
List<Marker> markers = getModuleMarkers();
assertEquals(3, markers.size());
assertEquals(4, markers.size());
Marker marker = markers.get(0);
assertEquals("4", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("6", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
marker = markers.get(1);
assertEquals("10", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("11", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
marker = markers.get(2);
assertEquals("22", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("16", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
marker = markers.get(3);
assertEquals("28", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
}
}

View File

@ -0,0 +1,55 @@
/*******************************************************************************
* 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.bsl.comment.check.itests;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.junit.Test;
import com._1c.g5.v8.dt.validation.marker.IExtraInfoKeys;
import com._1c.g5.v8.dt.validation.marker.Marker;
import com.e1c.v8codestyle.bsl.check.itests.AbstractSingleModuleTestBase;
import com.e1c.v8codestyle.bsl.comment.check.RedundantParametersSectionCheck;
/**
* Tests for {@link RedundantParametersSectionCheck} check.
*
* @author Dmitriy Marmyshev
*/
public class RedundantParametersSectionCheckTest
extends AbstractSingleModuleTestBase
{
public RedundantParametersSectionCheckTest()
{
super(RedundantParametersSectionCheck.class);
}
/**
* Test the documentation comment should not have parameter section for method without parameters
*
* @throws Exception the exception
*/
@Test
public void testAllMethodParametersShouldCheck() throws Exception
{
updateModule(FOLDER_RESOURCE + "doc-comment-redundant-parameter-section.bsl");
List<Marker> markers = getModuleMarkers();
assertEquals(1, markers.size());
Marker marker = markers.get(0);
assertEquals("2", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
}
}