ask-utils/ask-utils

View on GitHub

Showing 59 of 218 total issues

Function render has 500 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    render(isNormalMode) {
        let tp = lithtml.html(`
        <nav>
            <ul class="list">
                <li class="title">
Severity: Major
Found in docs/js/menu-wc.js - About 2 days to fix

    File menu-wc.js has 512 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    
    customElements.define('compodoc-menu', class extends HTMLElement {
        constructor() {
    Severity: Major
    Found in docs/js/menu-wc.js - About 1 day to fix

      File createRequestHandler.test.ts has 499 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /* eslint-disable @typescript-eslint/explicit-function-return-type */
      import {
          CustomSkillFactory
      } from 'ask-sdk-core'
      import {

        File model.ts has 379 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* eslint-disable import/export */
        
        export namespace Types {
            export type Locale = 'de-DE' | 'en-AU' | 'en-CA' | 'en-GB' | 'en-IN' | 'en-US' | 'es-ES' | 'es-MX' | 'fr-CA' | 'fr-FR' | 'it-IT' | 'ja-JP'
            export type dateTime = string
        Severity: Minor
        Found in packages/proactive-event/libs/model.ts - About 5 hrs to fix

          Function displayResults has 66 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function displayResults(res) {
                  var noResults = res.count == 0;
                  var groups = {};
                  $searchResults.toggleClass('no-results', noResults);
          
          
          Severity: Major
          Found in docs/js/search/search.js - About 2 hrs to fix

            Function init has 64 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static init (): PayloadBuilder {
                    const eventName = 'AMAZON.SportsEvent.Updated'
                    // eslint-disable-next-line @typescript-eslint/no-explicit-any
                    const eventLeague: Types.Soccer = {
                        name: 'localizedattribute:eventLeagueName'
            Severity: Major
            Found in packages/proactive-event/libs/SportsEvent/Updated/PayloadFactory.ts - About 2 hrs to fix

              Function init has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static init (): PayloadBuilder {
                      const eventName = 'AMAZON.Occasion.Updated'
                      const confirmationState: Types.ConfirmationState = {
                          confirmationStatus: 'CONFIRMED'
                      }
              Severity: Major
              Found in packages/proactive-event/libs/Occasion/Updated/PayloadFactory.ts - About 2 hrs to fix

                Function init has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static init (): PayloadBuilder {
                        const eventName = 'AMAZON.SocialGameInvite.Available'
                        // eslint-disable-next-line @typescript-eslint/no-explicit-any
                        const invite: any = {
                            inviter: {

                  Function init has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static init (): PayloadBuilder {
                          const eventName = 'AMAZON.MediaContent.Available'
                          // eslint-disable-next-line @typescript-eslint/no-explicit-any
                          const availability: any = {}
                          // eslint-disable-next-line @typescript-eslint/no-explicit-any

                    Function init has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static init (): PayloadBuilder {
                            const eventName = 'AMAZON.MessageAlert.Activated'
                            // eslint-disable-next-line @typescript-eslint/no-explicit-any
                            const state: any = {}
                            // eslint-disable-next-line @typescript-eslint/no-explicit-any

                      Function createSkill has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const createSkill = <T extends SkillConstants = SkillConstants>(config: SkillConfig<T>, handlers: SkillHandlers): CustomSkillBuilder => {
                          const skill = SkillBuilders.custom().withApiClient(new DefaultApiClient())
                          if (isS3Skill(config)) {
                              skill.withPersistenceAdapter(
                                  new S3PersistenceAdapter({
                      Severity: Minor
                      Found in packages/ask-utils/libs/skillBuilders.ts - About 1 hr to fix

                        Function init has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static init (): PayloadBuilder {
                                const eventName = 'AMAZON.OrderStatus.Updated'
                        
                                const order: Types.Order = {
                                    seller: {
                        Severity: Minor
                        Found in packages/proactive-event/libs/OrderStatus/Updated/PayloadFactory.ts - About 1 hr to fix

                          Function bindSearch has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function bindSearch() {
                                  // Bind DOM
                                  $searchInputs        = $('#book-search-input input');
                          
                                  $searchResults = $('.search-results');
                          Severity: Minor
                          Found in docs/js/search/search.js - About 1 hr to fix

                            Function getListProducts has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private getListProducts (): ResponseContent {
                                    const products = this.getProductLists()
                                    if (products.length === 1) {
                                        const productText = `<p>${products[0].name}. ${products[0].summary}</p>`
                                        if (this.isJP()) {
                            Severity: Minor
                            Found in packages/isp/libs/contentBuilders/List.ts - About 1 hr to fix

                              Function getLangNameByCode has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                              Open

                              export const getLangNameByCode = (code: PollyLanguage, lang: PollyLanguage = 'ja-JP'): string => {
                                  if (lang === 'ja-JP') {
                                      if (/^en/.test(code)) return '英語'
                                      if (/^es/.test(code)) return 'スペイン語'
                                      if (/^it/.test(code)) return 'イタリア語'
                              Severity: Minor
                              Found in packages/core/libs/amznPolly.ts - About 1 hr to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Function init has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public static init (): ErrorHandlerBuilder {
                                      let handlerFilter: ErrorHandle = (handlerInput) => {
                                          return handlerInput.responseBuilder
                                              .speak('Sorry I could not understand the meaning. Please tell me again')
                                              .reprompt('Could you tell me onece more?')
                              Severity: Minor
                              Found in packages/error-handlers/libs/index.ts - About 1 hr to fix

                                Function NoProductResponse has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export const NoProductResponse = (responseBuilder: ResponseBuilder, locale: string, products?: InskillProducts): Response => {
                                    const purchaseableProducts = products ? getAllPurchasableProducts(products) : []
                                    const purchaseableProductText = purchaseableProducts.map(product => product.name).join(', ')
                                    // no purchaseable products
                                    if (!purchaseableProductText) {
                                Severity: Minor
                                Found in packages/isp/libs/contentBuilders/generalResponse.ts - About 1 hr to fix

                                  Function init has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public static init (): PayloadBuilder {
                                          const eventName = 'AMAZON.TrashCollectionAlert.Activated'
                                          // eslint-disable-next-line @typescript-eslint/no-explicit-any
                                          let alert: any = {}
                                          return {

                                    Function handle has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        async handle (handlerInput: HandlerInput): Promise<Response> {
                                            const { requestEnvelope, responseBuilder, serviceClientFactory } = handlerInput
                                            const locale = getLocale(requestEnvelope)
                                            if (!serviceClientFactory) {
                                                const noISPResponse = UnSupportedISPResponse(locale)
                                    Severity: Minor
                                    Found in packages/isp/libs/handlers/Buy.ts - About 1 hr to fix

                                      Function init has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          public static init (): TranslationBuilder {
                                              const translationObject: TranslationObject | null = null
                                              const languageStrings: {
                                                  [lang: string]: TranslationObject;
                                              } = {}
                                      Severity: Minor
                                      Found in packages/core/libs/translator.ts - About 1 hr to fix

                                      Cognitive Complexity

                                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                      A method's cognitive complexity is based on a few simple rules:

                                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                      • Code is considered more complex for each "break in the linear flow of the code"
                                      • Code is considered more complex when "flow breaking structures are nested"

                                      Further reading

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language