namchey/linkpreview

View on GitHub

Showing 91 of 91 total issues

Function exports has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = (app) => {
  const defaultWhiteList = require(path.resolve('./server/cors/whitelist')).whitelist;
  const domainWhiteList = config.domains;
  const whiteList = defaultWhiteList.concat(domainWhiteList);
  const corsOptionsDelegate = function (req, callback) {
Severity: Minor
Found in server/express/cors.js - About 1 hr to fix

    Function app has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function app(state=initialState.app, action={}) {
    
      deepFreeze(state);
      switch (action.type) {
    
    
    Severity: Minor
    Found in app/reducers/app.js - About 1 hr to fix

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

            return renderContent({res, componentHTML: renderErrorPage(req, error), initialState, headconfig, chunkManifest, styles, scripts, metaProperties, status: 500});
      Severity: Major
      Found in app/Scrape/server.jsx and 1 other location - About 1 hr to fix
      app/Scrape/server.jsx on lines 172..172

      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

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

              return renderContent({res, componentHTML: renderErrorPage(req, error), initialState, headconfig, chunkManifest, styles, scripts, metaProperties, status: 500});
      Severity: Major
      Found in app/Scrape/server.jsx and 1 other location - About 1 hr to fix
      app/Scrape/server.jsx on lines 155..155

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

              value: function(value) {
      
                  // Steps 1-2.
                  if (this == null) {
                      throw new TypeError('this is null or not defined');
      Severity: Minor
      Found in app/utils/polyfills.js - 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 getEmbed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.getEmbed = function(req, res, next) {
      
          const url = req.query.url;
      
          const format = req.query.format || 'json';
      Severity: Minor
      Found in modules/application/controllers/oembed.js - 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 track has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.track = ({req, config, agentInfo}) => {
        if(config.query) {
      
          if(!config.query.utm_source && !req.query.utm_source) return;
          if(!config.query.utm_medium && !req.query.utm_medium) return;
      Severity: Minor
      Found in modules/application/services/utm-tracking.js - 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 render has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          render() {
              const { children, dispatch, appLoaded, netError, appMessage, showNetErrorComponent } = this.props;
              return (
                <div>
                  <div className={cx('app')}>
      Severity: Minor
      Found in app/Scrape/App.jsx - About 1 hr to fix

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

          render() {
            const { opengraph, scrape } = this.props;
            let hostname = '';
            if(opengraph['og:url']) {
              hostname = new URL(opengraph['og:url']).hostname;
        Severity: Minor
        Found in app/Scrape/OpenGraph/index.js - About 1 hr to fix

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

          const hanldeCallback = (req, res) => (err, json, body) => {  
            if(err) {
              return res.status(500).json(err);
            }
          
          
          Severity: Minor
          Found in modules/scrape/v1/controllers/index.js - About 1 hr to fix

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

            exports.server = (config) => {
              return [
                // Order the modules and chunks by occurrence.
                // This saves space, because often referenced modules
                // and chunks get smaller ids.
            Severity: Minor
            Found in webpack/production/common-plugins.prod.js - About 1 hr to fix

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

                      {Object.keys(body).length && (<pre className={cx('detail')}>
                        {JSON.stringify(body, null, 2)}
                      </pre>)}
              Severity: Major
              Found in app/Scrape/Oembed/index.js and 2 other locations - About 1 hr to fix
              app/Scrape/OpenGraph/index.js on lines 76..78
              app/Scrape/TwitterCard/index.js on lines 90..92

              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 3 locations. Consider refactoring.
              Open

                      {Object.keys(twittercard).length && (<pre className={cx('detail')}>
                        {JSON.stringify(twittercard, null, 2)}
                      </pre>)}
              Severity: Major
              Found in app/Scrape/TwitterCard/index.js and 2 other locations - About 1 hr to fix
              app/Scrape/Oembed/index.js on lines 38..40
              app/Scrape/OpenGraph/index.js on lines 76..78

              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 3 locations. Consider refactoring.
              Open

                      {Object.keys(opengraph).length && (<pre className={cx('detail')}>
                        {JSON.stringify(opengraph, null, 2)}
                      </pre>)}
              Severity: Major
              Found in app/Scrape/OpenGraph/index.js and 2 other locations - About 1 hr to fix
              app/Scrape/Oembed/index.js on lines 38..40
              app/Scrape/TwitterCard/index.js on lines 90..92

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

              exports.publish = (config, req) => {
              
                  /* sample config object
                  {
                   action: 'viewed',
              Severity: Minor
              Found in modules/application/services/events.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

              Function forwardHeaders has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              export const forwardHeaders = ({req, axios, authenticated, isStaging}) => {
                const requestInterceptor = axios.interceptors.request.use( (config) => {
                  if(req.headers['user-agent']) {
                    config.headers['user-agent'] = req.headers['user-agent'];
                  }
              Severity: Minor
              Found in app/Scrape/server.jsx - 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

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

                  if(req && req.headers && checkCrawler(req.headers['user-agent'])) {
                     promises = needs.map((need) => {
                      return dispatch(need({...params, crawler: req.headers['user-agent']}));
                    });
                  } else if(req) {
              Severity: Minor
              Found in app/middlewares/preRenderMiddleware.js and 1 other location - About 55 mins to fix
              app/middlewares/preRenderMiddleware.js on lines 31..35

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

              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

                requestPromise({uri}).then(res => {
                  json.oembed.body = res;
                  res.status(200).json({json, body});
                }).catch(err => {
              Severity: Minor
              Found in modules/scrape/v1/controllers/index.js and 1 other location - About 55 mins to fix
              modules/scrape/v1/controllers/index.js on lines 91..97

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

              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

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

                  } else if(req) {
                    promises = needs.map((need) => {
                      return dispatch(need({...params, crawler: req.headers['user-agent']}));
                    });
                  }
              Severity: Minor
              Found in app/middlewares/preRenderMiddleware.js and 1 other location - About 55 mins to fix
              app/middlewares/preRenderMiddleware.js on lines 27..35

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

              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 4 locations. Consider refactoring.
              Open

                    {error ? <div className={cx('alert', 'alert-danger')}>
                      <b>{error}</b>
                      {closeButton}
                    </div>: '' }
              Severity: Major
              Found in app/components/Message/index.js and 3 other locations - About 50 mins to fix
              app/components/Message/index.js on lines 14..17
              app/components/Message/index.js on lines 22..25
              app/components/Message/index.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 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

              Severity
              Category
              Status
              Source
              Language