Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
}

function includesTypeNames(inputMap) {
const flagMatch = inputMap.request.URI.match(new RegExp("[?&]include_type_name=([^&#]*)"));

Check failure on line 168 in transformation/transformationPlugins/jsonMessageTransformers/jsonTypeMappingsSanitizationTransformer/src/main/resources/js/typeMappingsSanitizer.js

View workflow job for this annotation

GitHub Actions / Run SonarQube Analysis

javascript:S6325

Use a regular expression literal instead of the 'RegExp' constructor.
if (flagMatch) {
return JSON.parse(flagMatch[1]);
}
Expand Down Expand Up @@ -238,7 +238,7 @@

const newProperties = {}
for (const [sourceType,] of targetIndicesMap) {
for (fieldName of oldMappings[sourceType].properties.keys()) {
for (const fieldName of oldMappings[sourceType].properties.keys()) {
if (newProperties[fieldName]) {
const previouslyProcessedFieldDef = newProperties[fieldName];
const currentlyProcessingFieldDef = oldMappings[sourceType].properties[fieldName];
Expand All @@ -263,7 +263,7 @@
return inputMap.request;
}

const sourceIndex = match[1].replace(new RegExp("[?].*"), ""); // remove the query string that could be after

Check failure on line 266 in transformation/transformationPlugins/jsonMessageTransformers/jsonTypeMappingsSanitizationTransformer/src/main/resources/js/typeMappingsSanitizer.js

View workflow job for this annotation

GitHub Actions / Run SonarQube Analysis

javascript:S6325

Use a regular expression literal instead of the 'RegExp' constructor.
const types = [...mappings.keys()];
const sourceTypeToTargetIndicesMap = new Map(types
.map(type => [type, convertSourceIndexToTarget(sourceIndex, type, inputMap.index_mappings, inputMap.regex_mappings)])
Expand All @@ -281,7 +281,7 @@
const INDEX_TYPE_BULK_REQUEST_REGEX = /(?:PUT|POST) \/([^/]+)\/([^/]+)\/_bulk/;
const BULK_URI_INDEX_PATTERN_REGEX = /^.+\/(?:[^/]+\/)?_bulk/;

function processMetadataRequest(document, context) {

Check failure on line 284 in transformation/transformationPlugins/jsonMessageTransformers/jsonTypeMappingsSanitizationTransformer/src/main/resources/js/typeMappingsSanitizer.js

View workflow job for this annotation

GitHub Actions / Run SonarQube Analysis

javascript:S3776

Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed.
let mappings = document?.body?.mappings;

// Normalize mappings to an object
Expand Down Expand Up @@ -454,7 +454,7 @@
function main(context) {
console.log("Context: ", JSON.stringify(context, mapToPlainObjectReplacer, 2));

// Validate context, todo: include more validation

Check failure on line 457 in transformation/transformationPlugins/jsonMessageTransformers/jsonTypeMappingsSanitizationTransformer/src/main/resources/js/typeMappingsSanitizer.js

View workflow job for this annotation

GitHub Actions / Run SonarQube Analysis

javascript:S1135

Complete the task associated to this "TODO" comment.
if (!context || !context?.source_properties?.version?.major) {
console.error("Context Missing source_properties: ", JSON.stringify(context, mapToPlainObjectReplacer, 2));
throw new Error("No source_properties defined - required to transform correctly!");
Expand Down
Loading