Function init
has 60 lines of code (exceeds 25 allowed). Consider refactoring.
function init(config, watch, options) {
const ctor = sanitizeConfig(config);
const keycloak = Keycloak(ctor);
watch.$once('ready', function (cb) {
Function install
has 55 lines of code (exceeds 25 allowed). Consider refactoring.
install: function (Vue, params = {}) {
if (installed) return;
installed = true;
const defaultParams = {
Function data
has 31 lines of code (exceeds 25 allowed). Consider refactoring.
data() {
return {
ready: false,
authenticated: false,
userName: null,
Function updateWatchVariables
has 29 lines of code (exceeds 25 allowed). Consider refactoring.
function updateWatchVariables(isAuthenticated = false) {
watch.authenticated = isAuthenticated;
watch.loginFn = keycloak.login;
watch.login = keycloak.login;
watch.createLoginUrl = keycloak.createLoginUrl;
Function exports
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
module.exports = function(service, e) {
if (e.response) {
let data;
if (typeof e.response.data === 'string' || e.response.data instanceof String) {
Function assertOptions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
function assertOptions(options) {
const { config, init, onReady, onInitError } = options;
if (typeof config !== 'string' && !_isObject(config)) {
return { hasError: true, error: `'config' option must be a string or an object. Found: '${config}'` };
}
Avoid too many return
statements within this function.
return {
hasError: false,
error: null
};
Function hasResourceRoles
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
hasResourceRoles: (_state, getters) => (resource, roles) => {
if (!getters.authenticated) return false;
if (!roles.length) return true;
if (getters.resourceAccess[resource]) {
Function login
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
login({ commit, getters }, idpHint = undefined) {
if (getters.keycloakReady) {
if (!getters.redirectUri) commit('SET_REDIRECTURI', location.toString());