TelescopeJS/Telescope

View on GitHub

Showing 26 of 26 total issues

Function github has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function github(telescope) {
  // telescope
  const defaultPlugin = telescope.defaultPlugin
  return {
    condition(url) {
Severity: Minor
Found in src/core/plugins/github.js - About 2 hrs 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 handle has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function handle(query, req, res, next) {
  // '/pdf' | '/img'
  const {
    style,
    hlStyle,
Severity: Major
Found in src/server/route.js - About 2 hrs to fix

    Function github has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function github(telescope) {
      // telescope
      const defaultPlugin = telescope.defaultPlugin
      return {
        condition(url) {
    Severity: Minor
    Found in src/core/plugins/github.js - About 2 hrs to fix

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

      specRouter.all('/style/:style.css', (req, res, next) => {
        const { style } = req.params
        // Telescope.styleGetter[style] exports filename in nodejs.
        res.sendFile(Telescope.styleGetter[style], {
          headers: {
      Severity: Major
      Found in src/server/route.js and 1 other location - About 1 hr to fix
      src/server/route.js on lines 141..149

      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 73.

      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

      specRouter.all('/hl/:style.css', (req, res, next) => {
        const { style } = req.params
        // Telescope.styleGetter[style] exports filename in nodejs.
        res.sendFile(Telescope.hlStyleGetter[style], {
          headers: {
      Severity: Major
      Found in src/server/route.js and 1 other location - About 1 hr to fix
      src/server/route.js on lines 126..134

      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 73.

      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 see has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async see(url) {
          const matchedPlugin = this.plugins.find(plugin =>
            plugin.condition(url)
          )
      
      
      Severity: Minor
      Found in src/core/index.js - About 1 hr to fix

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

        async function saveImg(url, key, options = {}) {
          const browser = await puppeteer.launch({ timeout: 100000, args: ['--no-sandbox', '--disable-setuid-sandbox'] })
          const page = await browser.newPage()
          await page.goto(url, { waitUntil: 'networkidle2', timeout: 100000 })
          // await page.waitFor('img')
        Severity: Minor
        Found in src/server/headless.js - About 1 hr to fix

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

            render() {
              return (
                <div>
                  {(
                     this.local.inputVisible || this.local.styleSelectVisible
          Severity: Minor
          Found in src/client/ViewModel/App/View.js - About 1 hr to fix

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

              test('parse normal', () => {
                expect(
                  parseGithubUrl('https://github.com/imcuttle/picidae/blob/master/test/demo/template.html')
                ).toMatchObject({
                  hostname: 'github.com',
            Severity: Major
            Found in src/core/utils/parseGithubUrl.test.js and 1 other location - About 1 hr to fix
            src/core/utils/parseGithubUrl.test.js on lines 36..47

            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 63.

            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

              test('parse raw url', () => {
                expect(
                  parseGithubUrl('https://raw.githubusercontent.com/imcuttle/markdown-it-github-headings/dev/test/index.js')
                ).toMatchObject({
                  hostname: 'raw.githubusercontent.com',
            Severity: Major
            Found in src/core/utils/parseGithubUrl.test.js and 1 other location - About 1 hr to fix
            src/core/utils/parseGithubUrl.test.js on lines 10..21

            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 63.

            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 fetch has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async fetch(url) {
                  // NOTE: parse-github-url use cache
                  const obj = { ...parseGithub(url) }
                  let response
                  // console.error(obj)
            Severity: Minor
            Found in src/core/plugins/github.js - About 1 hr to fix

              Function markdown has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default async function markdown(markdown, options = {}) {
                const {
                  markdownItOptions = {},
                  fromUrl           = '',
                  transformers      = [],
              Severity: Minor
              Found in src/core/utils/markdown.js - About 1 hr to fix

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

                export default function getTypeFromURL(path = '') {
                  const { pathname } = url.parse(path)
                  return nps.extname(pathname).replace(/^\./, '')
                }
                Severity: Major
                Found in src/core/utils/getTypeFromContentType.js and 1 other location - About 1 hr to fix
                src/core/utils/getInformationFromURL.js on lines 12..15

                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 55.

                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 function extname(path = '') {
                  const { pathname } = url.parse(path)
                  return nps.extname(pathname).replace(/^\./, '')
                }
                Severity: Major
                Found in src/core/utils/getInformationFromURL.js and 1 other location - About 1 hr to fix
                src/core/utils/getTypeFromContentType.js on lines 10..13

                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 55.

                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 see has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  async see(url) {
                    const matchedPlugin = this.plugins.find(plugin =>
                      plugin.condition(url)
                    )
                
                
                Severity: Minor
                Found in src/core/index.js - About 55 mins 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

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

                specRouter.all('/print.css', function (req, res) {
                  res.sendFile(require.resolve('./print.css'), {
                    headers: {
                      'Content-Type': 'text/css; charset=utf-8'
                    }
                Severity: Minor
                Found in src/server/route.js and 1 other location - About 50 mins to fix
                src/server/route.js on lines 112..118

                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 51.

                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

                specRouter.all('/style.css', function (req, res) {
                  res.sendFile(require.resolve('../client/index.css'), {
                    headers: {
                      'Content-Type': 'text/css; charset=utf-8'
                    }
                Severity: Minor
                Found in src/server/route.js and 1 other location - About 50 mins to fix
                src/server/route.js on lines 119..125

                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 51.

                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

                  setHlStyle(style = 'github') {
                    this.hlStyle = this.telescope.options.hlStyle = style
                    this.loadHlStyle()
                  }
                Severity: Minor
                Found in src/client/ViewModel/App/index.js and 1 other location - About 45 mins to fix
                src/client/ViewModel/App/index.js on lines 81..84

                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 50.

                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

                  setStyle(style = 'github') {
                    this.style = this.telescope.options.style = style
                    this.loadStyle()
                  }
                Severity: Minor
                Found in src/client/ViewModel/App/index.js and 1 other location - About 45 mins to fix
                src/client/ViewModel/App/index.js on lines 86..89

                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 50.

                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

                  changeHlStyle = evt => {
                    const val = evt.target.selectedOptions[0].value
                    this.local.setHlStyle(val)
                  }
                Severity: Minor
                Found in src/client/ViewModel/App/View.js and 1 other location - About 40 mins to fix
                src/client/ViewModel/App/View.js on lines 26..29

                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 49.

                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

                Severity
                Category
                Status
                Source
                Language