Similar blocks of code found in 3 locations. Consider refactoring.
function (req, res) {
return rq.post("https://api.spotify.com/v1/me/player/next", req.getSession().details.user.accessToken)
.then((r) => {
req.getSession().set("statusCode", r.statusCode);
Similar blocks of code found in 3 locations. Consider refactoring.
function (req, res) {
return rq.put("https://api.spotify.com/v1/me/player/pause", req.getSession().details.user.accessToken)
.then((r) => {
req.getSession().set("statusCode", r.statusCode);
Similar blocks of code found in 3 locations. Consider refactoring.
function (req, res) {
return rq.post("https://api.spotify.com/v1/me/player/previous", req.getSession().details.user.accessToken)
.then((r) => {
req.getSession().set("statusCode", r.statusCode);
File connect.js
has 490 lines of code (exceeds 250 allowed). Consider refactoring.
const alexa = require('alexa-app');
const request = require('request-promise-native');
const express = require('express');
const nodecache = require('node-cache');
const i18n = require('i18n');
Function getAndValidateVolumePercentFromSlot
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
const getAndValidateVolumePercentFromSlot = (req, res, isPercentIntent) => {
const slotName = isPercentIntent ? "VOLUMEPERCENT" : "VOLUMELEVEL"
if (req.slot(slotName)) {
Similar blocks of code found in 2 locations. Consider refactoring.
app.intent('VolumeLevelIntent', {
"slots": {
"VOLUMELEVEL": "AMAZON.NUMBER"
},
"utterances": [
Similar blocks of code found in 2 locations. Consider refactoring.
app.intent('VolumePercentIntent', {
"slots": {
"VOLUMEPERCENT": "AMAZON.NUMBER"
},
"utterances": [
Similar blocks of code found in 2 locations. Consider refactoring.
if (DEVICE) {
return findDeviceByName(req, cache, DEVICE).then(async (device) => {
if (device.id) {
Similar blocks of code found in 2 locations. Consider refactoring.
if (DEVICE) {
return findDeviceByName(req, cache, DEVICE).then(async (device) => {
if (device.id) {
Identical blocks of code found in 2 locations. Consider refactoring.
if (device.id) {
await request.put({
url: "https://api.spotify.com/v1/me/player",
Identical blocks of code found in 2 locations. Consider refactoring.
if (device.id) {
await request.put({
url: "https://api.spotify.com/v1/me/player",
Function generatedLocales
has 37 lines of code (exceeds 25 allowed). Consider refactoring.
const generatedLocales = Object.entries(locales).map(([name, locale]) => {
let skillbuilder = {
"intents": [
{
"name": "AMAZON.HelpIntent",
Function getAndValidateVolumePercentFromSlot
has 33 lines of code (exceeds 25 allowed). Consider refactoring.
const getAndValidateVolumePercentFromSlot = (req, res, isPercentIntent) => {
const slotName = isPercentIntent ? "VOLUMEPERCENT" : "VOLUMELEVEL"
if (req.slot(slotName)) {
Similar blocks of code found in 2 locations. Consider refactoring.
request.get({
url: "https://api.spotify.com/v1/me/player/devices",
auth: {
"bearer": req.getSession().details.user.accessToken
Similar blocks of code found in 2 locations. Consider refactoring.
return request.get({
url: "https://api.spotify.com/v1/me/player/currently-playing",
auth: {
"bearer": req.getSession().details.user.accessToken
Similar blocks of code found in 2 locations. Consider refactoring.
res.say(req.context.__("This is {{name}} by {{artist}}", { name: body.item.name, artist: body.item.artists[0].name }));
Similar blocks of code found in 2 locations. Consider refactoring.
res.say(req.context.__("That was {{name}} by {{artist}}", { name: body.item.name, artist: body.item.artists[0].name }));
Identical blocks of code found in 2 locations. Consider refactoring.
return request.get({
url: `https://api.spotify.com/v1/search`,
auth: {
bearer: req.getSession().details.user.accessToken,
Identical blocks of code found in 2 locations. Consider refactoring.
return request.post({
url: "https://api.spotify.com/v1/me/player/queue",
auth: {
bearer: req.getSession().details.user.accessToken,
},