Skip to content

Commit 0a363c6

Browse files
committed
WIP Sonar
1 parent 432c516 commit 0a363c6

File tree

11 files changed

+886
-905
lines changed

11 files changed

+886
-905
lines changed

src/main/server/adapter/asn/asn.js

Lines changed: 291 additions & 300 deletions
Large diffs are not rendered by default.

src/main/server/adapter/case/caseAdapter.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ cfClean = function (o) {
126126
}
127127

128128
var ordered = {};
129-
Object.keys(o).sort().forEach(function (key) {
129+
Object.keys(o).sort().forEach(function (key) { // NOSONAR - Programmatic sort is necessary
130130
ordered[key] = o[key];
131131
delete o[key];
132132
});
@@ -137,12 +137,12 @@ cfClean = function (o) {
137137
}
138138

139139
/*Errors:
140-
400 - An invalid selection field was supplied and data filtering on the selection criteria was not possible i.e. 'invalid_selection_field'. This is accompanied by the 'codeMajor/severity' values of 'failure/error'. The payload structure is defined by the structure imsx_StatusInfo.Type.
141-
401 - The request was not correctly authorised i.e. 'unauthorisedrequest'. This would be accompanied by the 'codeMajor/severity' values of 'failure/error'. The payload structure is defined by the structure imsx_StatusInfo.Type.
142-
403 - This is used to indicate that the server can be reached and process the request but refuses to take any further action i.e. 'forbidden'. This would be accompanied by the 'codeMajor/severity' values of 'failure/error'. The payload structure is defined by the structure imsx_StatusInfo.Type.
143-
404 - Either the supplied identifier is unknown in the Service Provider and so the object could not be changed or an invalid UUID has been supplied. This would be accompanied by the 'codeMajor/severity' values of 'failure/error'. The statement 'Unknown Object' of 'Invalid UUID' should also be presented. The payload structure is defined by the structure imsx_StatusInfo.Type.
144-
429 - The server is receiving too many requests i.e. 'server_busy'. Retry at a later time. This would be accompanied by the 'codeMajor/severity' values of 'failure/error'. The payload structure is defined by the structure imsx_StatusInfo.Type.
145-
500 - This code should be used only if there is catastrophic error and there is not a more appropriate code i.e. 'internal_server_error'. This would be accompanied by the 'codeMajor/severity' values of 'failure/error'. The payload structure is defined by the structure imsx_StatusInfo.Type.
140+
400 - An invalid selection field was supplied and data filtering on the selection criteria was not possible i.e. 'invalid_selection_field'. This is accompanied by the 'codeMajor/severity' values of 'failure/error'. The payload structure is defined by the structure imsx_StatusInfo.Type.
141+
401 - The request was not correctly authorised i.e. 'unauthorisedrequest'. This would be accompanied by the 'codeMajor/severity' values of 'failure/error'. The payload structure is defined by the structure imsx_StatusInfo.Type.
142+
403 - This is used to indicate that the server can be reached and process the request but refuses to take any further action i.e. 'forbidden'. This would be accompanied by the 'codeMajor/severity' values of 'failure/error'. The payload structure is defined by the structure imsx_StatusInfo.Type.
143+
404 - Either the supplied identifier is unknown in the Service Provider and so the object could not be changed or an invalid UUID has been supplied. This would be accompanied by the 'codeMajor/severity' values of 'failure/error'. The statement 'Unknown Object' of 'Invalid UUID' should also be presented. The payload structure is defined by the structure imsx_StatusInfo.Type.
144+
429 - The server is receiving too many requests i.e. 'server_busy'. Retry at a later time. This would be accompanied by the 'codeMajor/severity' values of 'failure/error'. The payload structure is defined by the structure imsx_StatusInfo.Type.
145+
500 - This code should be used only if there is catastrophic error and there is not a more appropriate code i.e. 'internal_server_error'. This would be accompanied by the 'codeMajor/severity' values of 'failure/error'. The payload structure is defined by the structure imsx_StatusInfo.Type.
146146
*/
147147
cfDocuments = async function (f, terms) {
148148
f = await cfGetFramework.call(this, f);

src/main/server/adapter/ce/pna.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55
// https://docs.google.com/document/d/1w_0HDNIA9GZq76txOuS8e-OhmKJiHe9Azjuq1BfrxQ0/edit
66

77
async function pnaEndpoint() {
8-
9-
EcRepository.cache = new Object();
8+
EcRepository.cache = {};
109
EcRepository.caching = true;
11-
if (false && repoEndpoint().contains("localhost"))
12-
error("Endpoint Configuration is not set.", 500);
13-
var query = queryParse.call(this);
14-
var framework = null;
10+
let query = queryParse.call(this);
11+
let framework = null;
1512
if (framework == null)
1613
framework = await skyrepoGet.call(this, query);
1714

@@ -27,7 +24,7 @@ async function pnaEndpoint() {
2724
}
2825

2926
// Data from the framework to be stored in Competency Explorer registry for indexing
30-
let pnaData = new Object();
27+
let pnaData = {};
3128

3229
const now = new Date();
3330
const formattedNow = now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate();
@@ -60,23 +57,24 @@ async function pnaEndpoint() {
6057
name: framework["name"],
6158
description: framework["description"],
6259
attributionName: attribution.startsWith('http') ? "" : attribution,
63-
attributionURL: attribution.startsWith('http') ? attribution : "",
60+
attributionURL: attribution.startsWith('http') ? attribution : "",
6461
beneficiaryRights: framework["ceasn:license"] ? framework["ceasn:license"] : (framework["schema:license"] ? framework["schema:license"] : ""),
6562
dataURL: ceasnEndpointFramework + query["id"],
66-
providerMetaModel: process.env.PNA_PROVIDER_META_MODEL ?process.env. PNA_PROVIDER_META_MODEL : "",
63+
providerMetaModel: process.env.PNA_PROVIDER_META_MODEL ? process.env.PNA_PROVIDER_META_MODEL : "",
6764
registryRights: process.env.PNA_REGISTRY_RIGHTS ? process.env.PNA_REGISTRY_RIGHTS : "",
6865
};
69-
66+
7067
if (framework.competency == null) framework.competency = [];
7168

7269
let competencies = [];
7370
const promises = [];
74-
framework.competency.forEach(cid => {
71+
framework.competency.forEach((cid) => {
7572
promises.push(EcRepository.get(
76-
EcRemoteLinkedData.trimVersionFromUrl(cid),
77-
null,
78-
null,
79-
repo).then((expanded) => {
73+
EcRemoteLinkedData.trimVersionFromUrl(cid),
74+
null,
75+
null,
76+
repo
77+
).then((expanded) => {
8078
if (expanded && expanded["id"]) {
8179
match = expanded["id"].match('(.*)(\/data\/)(.*)');
8280
let ceasnEndpoint = match && match.length > 1 ? match[1] + "/ceasn/" : undefined;
@@ -108,12 +106,11 @@ async function pnaEndpoint() {
108106
return JSON.stringify(result);
109107
} else {
110108
return JSON.stringify(pnaData);
111-
}
109+
}
112110
}
113111

114112
async function uploadToAws(data, name) {
115-
116-
const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3");
113+
const {S3Client, PutObjectCommand} = require("@aws-sdk/client-s3");
117114

118115
const AWS_REGION = process.env.PNA_AWS_REGION ? process.env.PNA_AWS_REGION : "";
119116
const AWS_BUCKET = process.env.PNA_AWS_BUCKET ? process.env.PNA_AWS_BUCKET : "";
@@ -127,14 +124,14 @@ async function uploadToAws(data, name) {
127124
return {
128125
framework: undefined,
129126
success: false
130-
};
127+
};
131128
}
132129
if (!AWS_REGION) {
133130
global.auditLogger.report(global.auditLogger.LogCategory.ADAPTER, global.auditLogger.Severity.ERROR, "pnaUploadErr", 'No AWS Region provided');
134131
return {
135132
framework: name,
136133
success: false
137-
};
134+
};
138135
}
139136
if (!AWS_BUCKET) {
140137
global.auditLogger.report(global.auditLogger.LogCategory.ADAPTER, global.auditLogger.Severity.ERROR, "pnaUploadErr", 'No AWS Bucket provided');
@@ -181,7 +178,7 @@ async function uploadToAws(data, name) {
181178
return {
182179
framework: name,
183180
success: success
184-
};
181+
};
185182
} catch (err) {
186183
global.auditLogger.report(global.auditLogger.LogCategory.ADAPTER, global.auditLogger.Severity.ERROR, "pnaUploadErr", name);
187184
global.auditLogger.report(global.auditLogger.LogCategory.ADAPTER, global.auditLogger.Severity.ERROR, "pnaUploadErr", err);

0 commit comments

Comments
 (0)