AlexRogalskiy/wotd

View on GitHub

Showing 32 of 32 total issues

File themes.ts has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Optional } from '../../typings/standard-types'
import { ThemePattern } from '../../typings/enum-types'
import { ThemeOptions } from '../../typings/domain-types'

/**
Severity: Minor
Found in src/themes/themes.ts - About 3 hrs to fix

    Function style has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            style: (options: StyleOptions) => {
                const { primaryColor, secondaryColor, bgColor, pattern, opacity, colorPattern } = options.theme
    
                const fontPrimary = getFont(FontPattern.monserrat)
                const fontSecondary = getFont(FontPattern.monserrat_700)
    Severity: Major
    Found in src/layouts/default.layout.ts - About 3 hrs to fix

      File fonts.ts has 284 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { readFileSync } from 'fs'
      
      import { Optional } from '../../typings/standard-types'
      import { FontOptions } from '../../typings/domain-types'
      import { FontPattern } from '../../typings/enum-types'
      Severity: Minor
      Found in src/fonts/fonts.ts - About 2 hrs to fix

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

        export const fetchAsText = async (url: string, options: RequestInit = {}): Promise<string> => {
            try {
                const response = await fetch(url, options)
                const data = await checkStatus(response)
        
        
        Severity: Major
        Found in src/utils/requests.ts and 1 other location - About 2 hrs to fix
        src/utils/requests.ts on lines 38..48

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 83.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

        export const fetchAsJson = async (url: string, options: RequestInit = {}): Promise<any> => {
            try {
                const response = await fetch(url, options)
                const data = await checkStatus(response)
        
        
        Severity: Major
        Found in src/utils/requests.ts and 1 other location - About 2 hrs to fix
        src/utils/requests.ts on lines 26..36

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 83.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

        export async function templateController(req: NowRequest, res: NowResponse): Promise<NowResponse> {
            try {
                const { theme, layout, animation, language, width, height, ...rest } = req.query
                const { primaryColor, secondaryColor, bgColor, colorPattern, opacity, pattern } = rest
        
        
        Severity: Minor
        Found in src/controllers/template.controller.ts - About 1 hr to fix

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

          async function main() {
              const res = await fetch(
                  'https://api.github.com/repos/AlexRogalskiy/wotd/releases/latest',
              );
              const { tag_name } = await res.json();
          Severity: Minor
          Found in scripts/changelog.js - About 1 hr to fix

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

            export const traceLogs = createLogger((message, ...args) =>
                console.trace(`${COLORS.CYAN}${getTime()}:${COLORS.RESET}`, message, args)
            )
            Severity: Major
            Found in src/utils/loggers.ts and 4 other locations - About 1 hr to fix
            src/utils/loggers.ts on lines 56..58
            src/utils/loggers.ts on lines 59..61
            src/utils/loggers.ts on lines 62..64
            src/utils/loggers.ts on lines 65..67

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

            export const warnLogs = createLogger((message, ...args) =>
                console.warn(`${COLORS.GREEN}${getTime()}:${COLORS.RESET}`, message, args)
            )
            Severity: Major
            Found in src/utils/loggers.ts and 4 other locations - About 1 hr to fix
            src/utils/loggers.ts on lines 56..58
            src/utils/loggers.ts on lines 59..61
            src/utils/loggers.ts on lines 65..67
            src/utils/loggers.ts on lines 68..70

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

            export const debugLogs = createLogger((message, ...args) =>
                console.debug(`${COLORS.BLUE}${getTime()}:${COLORS.RESET}`, message, args)
            )
            Severity: Major
            Found in src/utils/loggers.ts and 4 other locations - About 1 hr to fix
            src/utils/loggers.ts on lines 56..58
            src/utils/loggers.ts on lines 59..61
            src/utils/loggers.ts on lines 62..64
            src/utils/loggers.ts on lines 68..70

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

            export const errorLogs = createLogger((message, ...args) =>
                console.error(`${COLORS.RED}${getTime()}:${COLORS.RESET}`, message, args)
            )
            Severity: Major
            Found in src/utils/loggers.ts and 4 other locations - About 1 hr to fix
            src/utils/loggers.ts on lines 56..58
            src/utils/loggers.ts on lines 62..64
            src/utils/loggers.ts on lines 65..67
            src/utils/loggers.ts on lines 68..70

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

            export const logs = createLogger((message, ...args) =>
                console.log(`${COLORS.PURPLE}${getTime()}:${COLORS.RESET}`, message, args)
            )
            Severity: Major
            Found in src/utils/loggers.ts and 4 other locations - About 1 hr to fix
            src/utils/loggers.ts on lines 59..61
            src/utils/loggers.ts on lines 62..64
            src/utils/loggers.ts on lines 65..67
            src/utils/loggers.ts on lines 68..70

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 59.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function templateRenderer has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export async function templateRenderer(requestData: ParsedRequestData): Promise<string> {
                const {
                    fontPattern,
                    themePattern,
                    animationPattern,
            Severity: Minor
            Found in src/services/template.service.ts - About 1 hr to fix

              Function constructor has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  constructor(readonly type: ErrorType, readonly message: string) {
                      super(message)
              
                      Object.defineProperty(this, 'message', {
                          configurable: true,
              Severity: Minor
              Found in src/errors/errors.ts - About 1 hr to fix

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

                export const getTheme = (value: Optional<ThemePattern>): ThemeOptions => {
                    return value ? themes[value] : themes[ThemePattern.default]
                }
                Severity: Major
                Found in src/themes/themes.ts and 4 other locations - About 1 hr to fix
                src/animations/animations.ts on lines 39..41
                src/fonts/fonts.ts on lines 298..300
                src/layouts/layouts.ts on lines 25..27
                src/routes/routes.ts on lines 25..27

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 57.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                export const getLayout = (value: Optional<LayoutPattern>): LayoutOptions => {
                    return value ? layouts[value] : layouts[LayoutPattern.default]
                }
                Severity: Major
                Found in src/layouts/layouts.ts and 4 other locations - About 1 hr to fix
                src/animations/animations.ts on lines 39..41
                src/fonts/fonts.ts on lines 298..300
                src/routes/routes.ts on lines 25..27
                src/themes/themes.ts on lines 337..339

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 57.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                export const getRoute = (value: Optional<RoutePattern>): RouteFunction => {
                    return value ? routes[value] : routes[RoutePattern.default]
                }
                Severity: Major
                Found in src/routes/routes.ts and 4 other locations - About 1 hr to fix
                src/animations/animations.ts on lines 39..41
                src/fonts/fonts.ts on lines 298..300
                src/layouts/layouts.ts on lines 25..27
                src/themes/themes.ts on lines 337..339

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 57.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                export const getFont = (value: Optional<FontPattern>): FontOptions => {
                    return value ? fonts[value] : fonts[FontPattern.default]
                }
                Severity: Major
                Found in src/fonts/fonts.ts and 4 other locations - About 1 hr to fix
                src/animations/animations.ts on lines 39..41
                src/layouts/layouts.ts on lines 25..27
                src/routes/routes.ts on lines 25..27
                src/themes/themes.ts on lines 337..339

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 57.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                export const getAnimation = (value: Optional<AnimationPattern>): AnimationOptions => {
                    return value ? animations[value] : animations[AnimationPattern.default]
                }
                Severity: Major
                Found in src/animations/animations.ts and 4 other locations - About 1 hr to fix
                src/fonts/fonts.ts on lines 298..300
                src/layouts/layouts.ts on lines 25..27
                src/routes/routes.ts on lines 25..27
                src/themes/themes.ts on lines 337..339

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 57.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Function objToString has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                const objToString = (obj: any, defaultValue = 'null'): string => {
                    let res = ''
                    let i = 0
                
                    if (!obj) return defaultValue
                Severity: Minor
                Found in src/utils/commons.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