mirror of
https://github.com/1C-Company/v8-code-style.git
synced 2025-02-22 08:19:39 +02:00
Merge pull request #1316 from 1C-Company/bug/method-name-fix-npe
Исправление NPE
This commit is contained in:
commit
930890cb57
@ -116,6 +116,11 @@ public class AttachableEventHandlerNameCheck
|
||||
Invocation inv = (Invocation)object;
|
||||
FeatureAccess method = inv.getMethodAccess();
|
||||
String methodName = method.getName();
|
||||
if (methodName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String actionPattern = parameters.getString(PARAM_ACTION_PATTERN);
|
||||
if (!(method instanceof DynamicFeatureAccess) || StringUtils.isEmpty(actionPattern)
|
||||
|| inv.getParams().size() != 2 || !(inv.getParams().get(1) instanceof StringLiteral)
|
||||
|
@ -226,7 +226,12 @@ public class EventHandlerBooleanParamCheck
|
||||
int index = params.indexOf(param);
|
||||
|
||||
Map<CaseInsensitiveString, Event> eventHandlers = getAllModuleEvents(module);
|
||||
CaseInsensitiveString methodName = new CaseInsensitiveString(method.getName());
|
||||
String name = method.getName();
|
||||
if (name == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
CaseInsensitiveString methodName = new CaseInsensitiveString(name);
|
||||
Event event = eventHandlers.get(methodName);
|
||||
if (event == null && isCorrectModuleForCustomHandlers(module))
|
||||
{
|
||||
|
@ -130,13 +130,19 @@ public final class ExportMethodInCommandFormModuleCheck
|
||||
|
||||
if (method.isExport())
|
||||
{
|
||||
String name = method.getName();
|
||||
if (name == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (commandModule)
|
||||
{
|
||||
exportMethods.put(method.getName(), method);
|
||||
exportMethods.put(name, method);
|
||||
}
|
||||
else if (serverMethodCheck && clientMethodCheck)
|
||||
{
|
||||
exportMethods.put(method.getName(), method);
|
||||
exportMethods.put(name, method);
|
||||
}
|
||||
else if (serverMethodCheck ^ clientMethodCheck)
|
||||
{
|
||||
@ -146,7 +152,7 @@ public final class ExportMethodInCommandFormModuleCheck
|
||||
.intersect(serverMethodCheck ? Environments.ALL_SERVERS : Environments.ALL_CLIENTS);
|
||||
if (enivronmetsObject.containsAny(checkingEnvs))
|
||||
{
|
||||
exportMethods.put(method.getName(), method);
|
||||
exportMethods.put(name, method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class ExportProcedureMissingCommentCheck
|
||||
extends AbstractModuleStructureCheck
|
||||
{
|
||||
private static final String CHECK_ID = "export-procedure-missing-comment"; //$NON-NLS-1$
|
||||
|
||||
|
||||
@Override
|
||||
public String getCheckId()
|
||||
{
|
||||
@ -72,9 +72,14 @@ public class ExportProcedureMissingCommentCheck
|
||||
if (method.isExport() && verifyTopRegion(getTopParentRegion(method))
|
||||
&& isMethodHasNoComment(NodeModelUtils.findActualNodeFor(method)))
|
||||
{
|
||||
resultAceptor.addIssue(
|
||||
MessageFormat.format(Messages.ExportProcedureMissingCommentCheck_Export_procedure_missing_comment,
|
||||
method.getName()),
|
||||
String name = method.getName();
|
||||
if (name == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
resultAceptor.addIssue(MessageFormat
|
||||
.format(Messages.ExportProcedureMissingCommentCheck_Export_procedure_missing_comment, name),
|
||||
McorePackage.Literals.NAMED_ELEMENT__NAME);
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class ExtensionMethodPrefixCheck
|
||||
{
|
||||
String prefix = getNamePrefix((IExtensionProject)extension);
|
||||
String methodName = method.getName();
|
||||
if (!StringUtils.isEmpty(prefix) && !methodName.startsWith(prefix))
|
||||
if (methodName != null && !StringUtils.isEmpty(prefix) && !methodName.startsWith(prefix))
|
||||
{
|
||||
resultAceptor.addIssue(
|
||||
MessageFormat.format(Messages.ExtensionMethodPrefixCheck_Ext_method__0__should_have__1__prefix,
|
||||
|
@ -78,6 +78,10 @@ public final class ModuleEmptyMethodCheck
|
||||
{
|
||||
Method method = (Method)object;
|
||||
String methodName = method.getName();
|
||||
if (methodName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String excludeNamePattern = parameters.getString(EXCLUDE_METHOD_NAME_PATTERN_PARAMETER_NAME);
|
||||
boolean allowMethodComments = parameters.getBoolean(ALLOW_METHOD_COMMENTS_PARAMETER_NAME);
|
||||
|
@ -106,9 +106,15 @@ public class ModuleStructureEventRegionsCheck
|
||||
else if (!ModuleType.COMMON_MODULE.equals(moduleType) && !eventHandlersName.equalsIgnoreCase(name)
|
||||
&& method.isEvent())
|
||||
{
|
||||
String methodName = method.getName();
|
||||
if (methodName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
resultAceptor.addIssue(
|
||||
MessageFormat.format(Messages.ModuleStructureEventRegionsCheck_Event_handler__0__not_region__1,
|
||||
method.getName(), eventHandlersName), McorePackage.Literals.NAMED_ELEMENT__NAME);
|
||||
methodName, eventHandlersName),
|
||||
McorePackage.Literals.NAMED_ELEMENT__NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,7 @@ public class ModuleStructureMethodInRegionCheck
|
||||
protected void configureCheck(CheckConfigurer builder)
|
||||
{
|
||||
builder.title(Messages.ModuleStructureMethodInRegionCheck_Title)
|
||||
.description(
|
||||
Messages.ModuleStructureMethodInRegionCheck_Description)
|
||||
.description(Messages.ModuleStructureMethodInRegionCheck_Description)
|
||||
.complexity(CheckComplexity.NORMAL)
|
||||
.severity(IssueSeverity.MINOR)
|
||||
.issueType(IssueType.CODE_STYLE)
|
||||
@ -141,8 +140,14 @@ public class ModuleStructureMethodInRegionCheck
|
||||
|
||||
private void addIssue(ResultAcceptor resultAceptor, Method method, String regions)
|
||||
{
|
||||
String name = method.getName();
|
||||
if (name == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
resultAceptor.addIssue(MessageFormat.format(
|
||||
Messages.ModuleStructureMethodInRegionCheck_Method_should_be_placed_in_one_of_the_standard_regions,
|
||||
method.getName(), regions), McorePackage.Literals.NAMED_ELEMENT__NAME);
|
||||
Messages.ModuleStructureMethodInRegionCheck_Method_should_be_placed_in_one_of_the_standard_regions, name,
|
||||
regions), McorePackage.Literals.NAMED_ELEMENT__NAME);
|
||||
}
|
||||
}
|
||||
|
@ -144,6 +144,10 @@ public final class RedundantExportMethodCheck
|
||||
Module module = EcoreUtil2.getContainerOfType(method, Module.class);
|
||||
|
||||
String name = method.getName();
|
||||
if (name == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (isNotExclusion(parameters, method, monitor) && !isScheduledJobOrEventSubscription(module, name, monitor)
|
||||
&& !existLocalNotifyDescription(module, name, monitor) && !haveCallerInOtherModule(method, monitor))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user