Skip to content

Commit

Permalink
GH Action Standards
Browse files Browse the repository at this point in the history
  • Loading branch information
confused-Techie authored and github-actions[bot] committed Jan 27, 2024
1 parent a92561f commit 411f48d
Show file tree
Hide file tree
Showing 37 changed files with 152 additions and 592 deletions.
461 changes: 0 additions & 461 deletions docs/reference/Source_Documentation.md

Large diffs are not rendered by default.

48 changes: 39 additions & 9 deletions docs/resources/complexity-report.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Complexity report, 1/23/2024

* Mean per-function logical LOC: 14.663793103448276
* Mean per-function parameter count: 0.13017241379310346
* Mean per-function cyclomatic complexity: 1.170689655172414
* Mean per-function Halstead effort: 3426.6136676441265
* Mean per-module maintainability index: 68.88659389428372
* First-order density: 0.89179548156956%
* Change cost: 5.618311533888228%
# Complexity report, 1/27/2024

* Mean per-function logical LOC: 14.458333333333334
* Mean per-function parameter count: 0.15916666666666668
* Mean per-function cyclomatic complexity: 1.2483333333333335
* Mean per-function Halstead effort: 3318.2315431289767
* Mean per-module maintainability index: 68.928875276727
* First-order density: 0.8333333333333334%
* Change cost: 5.305555555555555%
* Core size: 100%

## /home/runner/work/package-backend/package-backend/jest.config.js
Expand Down Expand Up @@ -229,6 +229,36 @@
* Maintainability index: 85.19382950159975
* Dependency count: 27

## /home/runner/work/package-backend/package-backend/src/database/_constants.js

* Physical LOC: 6
* Logical LOC: 5
* Mean parameter count: 0
* Cyclomatic complexity: 1
* Cyclomatic complexity density: 20%
* Maintainability index: 74.35668985133891
* Dependency count: 0

## /home/runner/work/package-backend/package-backend/src/database/_utils.js

* Physical LOC: 19
* Logical LOC: 15
* Mean parameter count: 2
* Cyclomatic complexity: 6
* Cyclomatic complexity density: 40%
* Maintainability index: 65.95338088382414
* Dependency count: 0
* Function: **getOrderField**
* Line No.: 9
* Physical LOC: 15
* Logical LOC: 12
* Parameter count: 2
* Cyclomatic complexity: 6
* Cyclomatic complexity density: 50%
* Halstead difficulty: 2.25
* Halstead volume: 75.28421251514429
* Halstead effort: 169.38947815907466

## /home/runner/work/package-backend/package-backend/src/models/ssoHTML.js

* Physical LOC: 12
Expand Down
4 changes: 2 additions & 2 deletions src/database/_clause.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ module.exports = {
filterClause,
ownerClause,
serviceClause,
fileExtensionClause
}
fileExtensionClause,
};
4 changes: 2 additions & 2 deletions src/database/_constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
module.exports = {
defaults: {
engine: { atom: "*" },
license: "NONE"
}
license: "NONE",
},
};
57 changes: 24 additions & 33 deletions src/database/_export.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
const fs = require("fs");
const postgres = require("postgres");
const logger = require("../logger.js");
const {
DB_HOST,
DB_USER,
DB_PASS,
DB_DB,
DB_PORT,
DB_SSL_CERT
} = require("../config.js").getConfig();
const { DB_HOST, DB_USER, DB_PASS, DB_DB, DB_PORT, DB_SSL_CERT } =
require("../config.js").getConfig();

// While the below method of exporting the additional database modules is nonstandard
// it lets us accomplish several things:
Expand All @@ -28,58 +22,55 @@ let sqlStorage; // SQL Object to interact with the DB

function setupSQL() {
return process.env.PULSAR_STATUS === "dev" && process.env.MOCK_DB !== "false"
? postgres({
host: DB_HOST,
username: DB_USER,
database: DB_DB,
port: DB_PORT
})
: postgres({
host: DB_HOST,
username: DB_USER,
password: DB_PASS,
database: DB_DB,
port: DB_PORT,
ssl: {
rejectUnauthorized: true,
ca: fs.readFileSync(DB_SSL_CERT).toString()
}
});
? postgres({
host: DB_HOST,
username: DB_USER,
database: DB_DB,
port: DB_PORT,
})
: postgres({
host: DB_HOST,
username: DB_USER,
password: DB_PASS,
database: DB_DB,
port: DB_PORT,
ssl: {
rejectUnauthorized: true,
ca: fs.readFileSync(DB_SSL_CERT).toString(),
},
});
}

function getSqlStorage() {
return sqlStorage ??= setupSQL();
return (sqlStorage ??= setupSQL());
}

function wrapper(modToUse) {
// Return this function passing all args based on what module we need to use
return async (...args) => {
// Wrap all function calls in a try catch with a singular error handler
try {

// Call the function passing the `sqlStorage` object can other provided params
return modToUse.exec(getSqlStorage(), ...args);

} catch(err) {
} catch (err) {
// Generic Error Catcher for all database modules
return {
ok: false,
content: "Generic Error",
short: "server_error",
error: err
error: err,
};

}
};
};
}

const exportObj = {
shutdownSQL: async () => {
if (sqlStorage !== undefined) {
await sqlStorage.end();
logger.generic(1, "SQL Server Shutdown!");
}
}
},
};

// Add all other modules here:
Expand Down
2 changes: 1 addition & 1 deletion src/database/_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ function getOrderField(method, sql) {
}

module.exports = {
getOrderField
getOrderField,
};
2 changes: 1 addition & 1 deletion src/database/applyFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ module.exports = {
return {
ok: true,
};
}
},
};
2 changes: 1 addition & 1 deletion src/database/authCheckAndDeleteStateKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ module.exports = {
}

return { ok: true, content: command[0].keycode };
}
},
};
2 changes: 1 addition & 1 deletion src/database/authStoreStateKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ module.exports = {
content: `The state key has not been saved on the database.`,
short: "server_error",
};
}
},
};
5 changes: 3 additions & 2 deletions src/database/getFeaturedPackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
*/

const storage = require("../storage.js");
const getPackageCollectionByName = require("./getPackageCollectionByName.js").exec;
const getPackageCollectionByName =
require("./getPackageCollectionByName.js").exec;

module.exports = {
safe: false,
Expand All @@ -20,5 +21,5 @@ module.exports = {
}

return await getPackageCollectionByName(sql, featuredArray.content);
}
},
};
5 changes: 3 additions & 2 deletions src/database/getFeaturedThemes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* @returns {object} A server status object.
*/
const storage = require("../storage.js");
const getPackageCollectionByName = require("./getPackageCollectionByName.js").exec;
const getPackageCollectionByName =
require("./getPackageCollectionByName.js").exec;

module.exports = {
safe: false,
Expand All @@ -18,5 +19,5 @@ module.exports = {
}

return await getPackageCollectionByName(sql, featuredThemeArray.content);
}
},
};
6 changes: 2 additions & 4 deletions src/database/getPackageByName.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ module.exports = {
JSONB_AGG(
JSON_BUILD_OBJECT(
${
user
? sql``
: sql`'id', v.id, 'package', v.package,`
user ? sql`` : sql`'id', v.id, 'package', v.package,`
} 'semver', v.semver, 'license', v.license, 'engine', v.engine, 'meta', v.meta,
'hasGrammar', v.has_grammar, 'hasSnippets', v.has_snippets,
'supportedLanguages', v.supported_languages
Expand All @@ -47,5 +45,5 @@ module.exports = {
content: `package ${name} not found.`,
short: "not_found",
};
}
},
};
2 changes: 1 addition & 1 deletion src/database/getPackageByNameSimple.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ module.exports = {
content: `Package ${name} not found.`,
short: "not_found",
};
}
},
};
2 changes: 1 addition & 1 deletion src/database/getPackageCollectionByID.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ module.exports = {
return command.count !== 0
? { ok: true, content: command }
: { ok: false, content: "No packages found.", short: "Not Found" };
}
},
};
2 changes: 1 addition & 1 deletion src/database/getPackageCollectionByName.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ module.exports = {
return command.count !== 0
? { ok: true, content: command }
: { ok: false, content: "No packages found.", short: "not_found" };
}
},
};
2 changes: 1 addition & 1 deletion src/database/getPackageVersionByNameAndVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ module.exports = {
content: `Package ${name} and Version ${version} not found.`,
short: "not_found",
};
}
},
};
12 changes: 7 additions & 5 deletions src/database/getSortedPackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ module.exports = {
INNER JOIN versions AS v ON (p.pointer = v.package AND v.deleted IS FALSE
${clause.queryClause(sql, opts)}
${clause.filterClause(sql, opts)}
${themes === true ? clause.filterClause(sql, { filter: "theme" }) : sql``})
${
themes === true
? clause.filterClause(sql, { filter: "theme" })
: sql``
})
WHERE p.name IS NOT NULL
Expand All @@ -60,9 +64,7 @@ module.exports = {
)
SELECT *, COUNT(*) OVER() AS query_result_count
FROM latest_versions
ORDER BY ${orderType} ${
opts.direction === "desc" ? sql`DESC` : sql`ASC`
}
ORDER BY ${orderType} ${opts.direction === "desc" ? sql`DESC` : sql`ASC`}
LIMIT ${limit}
OFFSET ${offset};
`;
Expand All @@ -82,5 +84,5 @@ module.exports = {
limit,
},
};
}
},
};
2 changes: 1 addition & 1 deletion src/database/getStarredPointersByUserID.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ module.exports = {
: [];

return { ok: true, content: packArray };
}
},
};
2 changes: 1 addition & 1 deletion src/database/getStarringUsersByPointer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ module.exports = {
}

return { ok: true, content: userArray };
}
},
};
2 changes: 1 addition & 1 deletion src/database/getUserByID.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ module.exports = {
content: `Unable to get user by ID: ${id}`,
short: "server_error",
};
}
},
};
2 changes: 1 addition & 1 deletion src/database/getUserByName.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ module.exports = {
content: `Unable to query for user: ${username}`,
short: "not_found",
};
}
},
};
2 changes: 1 addition & 1 deletion src/database/getUserByNodeID.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ module.exports = {
content: `Unable to get User By NODE_ID: ${id}`,
short: "server_error",
};
}
},
};
2 changes: 1 addition & 1 deletion src/database/getUserCollectionById.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ module.exports = {
}

return { ok: true, content: userArray };
}
},
};
2 changes: 1 addition & 1 deletion src/database/insertNewPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,5 @@ module.exports = {
error: err,
};
});
}
},
};
2 changes: 1 addition & 1 deletion src/database/insertNewPackageName.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ module.exports = {
error: err,
};
});
}
},
};
5 changes: 3 additions & 2 deletions src/database/insertNewPackageVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ module.exports = {
// The only requirement is that the provided semver is not already present
// in the database for the targeted package.

const license = packJSON.metadata.license ?? _constants.defaults.license;
const license =
packJSON.metadata.license ?? _constants.defaults.license;
const engine = packJSON.metadata.engines ?? _constants.defaults.engine;

let addVer = {};
Expand Down Expand Up @@ -155,5 +156,5 @@ module.exports = {
error: err,
};
});
}
},
};
2 changes: 1 addition & 1 deletion src/database/insertNewUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ module.exports = {
content: `Unable to create user: ${username}`,
short: "Server Error",
};
}
},
};
Loading

0 comments on commit 411f48d

Please sign in to comment.