thorpelawrence/alexa-spotify-connect

View on GitHub

Showing 19 of 19 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

function (req, res) {
// POST to Spotify REST API
return rq.post("https://api.spotify.com/v1/me/player/next", req.getSession().details.user.accessToken)
.then((r) => {
req.getSession().set("statusCode", r.statusCode);
Severity: Major
Found in connect.js and 2 other locations - About 7 hrs to fix
connect.js on lines 131..144
connect.js on lines 182..195

Similar blocks of code found in 3 locations. Consider refactoring.
Open

function (req, res) {
// PUT to Spotify REST API
return rq.put("https://api.spotify.com/v1/me/player/pause", req.getSession().details.user.accessToken)
.then((r) => {
req.getSession().set("statusCode", r.statusCode);
Severity: Major
Found in connect.js and 2 other locations - About 7 hrs to fix
connect.js on lines 156..169
connect.js on lines 182..195

Similar blocks of code found in 3 locations. Consider refactoring.
Open

function (req, res) {
// POST to Spotify REST API
return rq.post("https://api.spotify.com/v1/me/player/previous", req.getSession().details.user.accessToken)
.then((r) => {
req.getSession().set("statusCode", r.statusCode);
Severity: Major
Found in connect.js and 2 other locations - About 7 hrs to fix
connect.js on lines 131..144
connect.js on lines 156..169

File connect.js has 490 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const alexa = require('alexa-app');
const request = require('request-promise-native');
const express = require('express');
const nodecache = require('node-cache');
const i18n = require('i18n');
Severity: Minor
Found in connect.js - About 7 hrs to fix

    Function getAndValidateVolumePercentFromSlot has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    const getAndValidateVolumePercentFromSlot = (req, res, isPercentIntent) => {
    const slotName = isPercentIntent ? "VOLUMEPERCENT" : "VOLUMELEVEL"
    // Check that the slot has a value
    if (req.slot(slotName)) {
    // Check if the slot is a number
    Severity: Minor
    Found in connect.js - About 4 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    app.intent('VolumeLevelIntent', {
    "slots": {
    "VOLUMELEVEL": "AMAZON.NUMBER"
    },
    "utterances": [
    Severity: Major
    Found in connect.js and 1 other location - About 2 hrs to fix
    connect.js on lines 286..303

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    app.intent('VolumePercentIntent', {
    "slots": {
    "VOLUMEPERCENT": "AMAZON.NUMBER"
    },
    "utterances": [
    Severity: Major
    Found in connect.js and 1 other location - About 2 hrs to fix
    connect.js on lines 265..282

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    if (DEVICE) {
    return findDeviceByName(req, cache, DEVICE).then(async (device) => {
    // Check that the device was found
    if (device.id) {
    // PUT to Spotify REST API
    Severity: Major
    Found in connect.js and 1 other location - About 2 hrs to fix
    connect.js on lines 510..555

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    if (DEVICE) {
    return findDeviceByName(req, cache, DEVICE).then(async (device) => {
    // Check that the device was found
    if (device.id) {
    // PUT to Spotify REST API
    Severity: Major
    Found in connect.js and 1 other location - About 2 hrs to fix
    connect.js on lines 357..404

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    if (device.id) {
    // PUT to Spotify REST API
    await request.put({
    url: "https://api.spotify.com/v1/me/player",
    // Send access token as bearer auth
    Severity: Major
    Found in connect.js and 1 other location - About 1 hr to fix
    connect.js on lines 513..545

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    if (device.id) {
    // PUT to Spotify REST API
    await request.put({
    url: "https://api.spotify.com/v1/me/player",
    // Send access token as bearer auth
    Severity: Major
    Found in connect.js and 1 other location - About 1 hr to fix
    connect.js on lines 360..394

    Function generatedLocales has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const generatedLocales = Object.entries(locales).map(([name, locale]) => {
    let skillbuilder = {
    "intents": [
    {
    "name": "AMAZON.HelpIntent",
    Severity: Minor
    Found in skill/skill-i18n.js - About 1 hr to fix

      Function getAndValidateVolumePercentFromSlot has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const getAndValidateVolumePercentFromSlot = (req, res, isPercentIntent) => {
      const slotName = isPercentIntent ? "VOLUMEPERCENT" : "VOLUMELEVEL"
      // Check that the slot has a value
      if (req.slot(slotName)) {
      // Check if the slot is a number
      Severity: Minor
      Found in connect.js - About 1 hr to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        request.get({
        url: "https://api.spotify.com/v1/me/player/devices",
        // Send access token as bearer auth
        auth: {
        "bearer": req.getSession().details.user.accessToken
        Severity: Major
        Found in device-helper.js and 1 other location - About 1 hr to fix
        connect.js on lines 570..593

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        return request.get({
        url: "https://api.spotify.com/v1/me/player/currently-playing",
        // Send access token as bearer auth
        auth: {
        "bearer": req.getSession().details.user.accessToken
        Severity: Major
        Found in connect.js and 1 other location - About 1 hr to fix
        device-helper.js on lines 30..44

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        res.say(req.context.__("This is {{name}} by {{artist}}", { name: body.item.name, artist: body.item.artists[0].name }));
        Severity: Major
        Found in connect.js and 1 other location - About 1 hr to fix
        connect.js on lines 586..586

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        res.say(req.context.__("That was {{name}} by {{artist}}", { name: body.item.name, artist: body.item.artists[0].name }));
        Severity: Major
        Found in connect.js and 1 other location - About 1 hr to fix
        connect.js on lines 581..581

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        return request.get({
        url: `https://api.spotify.com/v1/search`,
        // Send access token as bearer auth
        auth: {
        bearer: req.getSession().details.user.accessToken,
        Severity: Minor
        Found in connect.js and 1 other location - About 50 mins to fix
        connect.js on lines 462..485

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        return request.post({
        url: "https://api.spotify.com/v1/me/player/queue",
        auth: {
        bearer: req.getSession().details.user.accessToken,
        },
        Severity: Minor
        Found in connect.js and 1 other location - About 50 mins to fix
        connect.js on lines 439..491
        Severity
        Category
        Status
        Source
        Language