mirror of
https://github.com/1C-Company/v8-code-style.git
synced 2025-04-17 14:06:40 +02:00
Исправление возможных NPE
This commit is contained in:
parent
b9cc1e397c
commit
524fdbc125
@ -150,7 +150,7 @@ public class FieldDefinitionTypeWithLinkRefCheck
|
||||
return false;
|
||||
}
|
||||
String typeName = type.getTypeName();
|
||||
return types.contains(typeName);
|
||||
return typeName != null && types.contains(typeName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -182,8 +182,10 @@ public abstract class AbstractDynamicFeatureAccessTypeCheck
|
||||
}
|
||||
|
||||
List<TypeItem> types = computeTypes(source, actualEnvs);
|
||||
return !monitor.isCanceled() && !types.isEmpty()
|
||||
&& types.stream().anyMatch(t -> typeNames.contains(McoreUtil.getTypeName(t)));
|
||||
return !monitor.isCanceled() && !types.isEmpty() && types.stream().anyMatch(t -> {
|
||||
String typeName = McoreUtil.getTypeName(t);
|
||||
return typeName != null && typeNames.contains(typeName);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -177,10 +177,11 @@ public class FunctionCtorReturnSectionCheck
|
||||
|
||||
Set<String> checkTypes = getCheckTypes(parameters);
|
||||
|
||||
List<String> computedReturnTypeNames = computedReturnTypes.stream()
|
||||
Set<String> computedReturnTypeNames = computedReturnTypes.stream()
|
||||
.map(McoreUtil::getTypeName)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (isUserDataTypes(computedReturnTypeNames, checkTypes))
|
||||
{
|
||||
|
||||
@ -208,16 +209,16 @@ public class FunctionCtorReturnSectionCheck
|
||||
for (TypeItem returnType : returnTypes)
|
||||
{
|
||||
String returnTypeName = McoreUtil.getTypeName(returnType);
|
||||
if (computedReturnTypeNames.contains(returnTypeName))
|
||||
if (returnTypeName != null && computedReturnTypeNames.contains(returnTypeName))
|
||||
{
|
||||
if (isUserDataTypes(List.of(returnTypeName), checkTypes))
|
||||
{
|
||||
Optional<Pair<Collection<Property>, TypeItem>> declaredProperties =
|
||||
coputedProperties.stream()
|
||||
.filter(t -> McoreUtil.getTypeName(t.getSecond()).equals(returnTypeName))
|
||||
.filter(t -> returnTypeName.equals(McoreUtil.getTypeName(t.getSecond())))
|
||||
.findAny();
|
||||
Optional<Pair<Collection<Property>, TypeItem>> typeProperties = properties.stream()
|
||||
.filter(t -> McoreUtil.getTypeName(t.getSecond()).equals(returnTypeName))
|
||||
.filter(t -> returnTypeName.equals(McoreUtil.getTypeName(t.getSecond())))
|
||||
.findAny();
|
||||
|
||||
checkTypeProperties(method, statment, isRussianScript, returnType,
|
||||
@ -321,7 +322,7 @@ public class FunctionCtorReturnSectionCheck
|
||||
return function.isExport();
|
||||
}
|
||||
|
||||
private boolean isUserDataTypes(List<String> computedReturnTypeNames, Set<String> checkTypes)
|
||||
private boolean isUserDataTypes(Collection<String> computedReturnTypeNames, Set<String> checkTypes)
|
||||
{
|
||||
if (computedReturnTypeNames.isEmpty())
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user