namchey/linkpreview

View on GitHub

Showing 54 of 91 total issues

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

    render() {

        const { routeLoading, isCodeLoading, appLoaded, locationBeforeTransitions } = this.props;
        const isLoading = !appLoaded || isCodeLoading || routeLoading;

Severity: Minor
Found in app/Scrape/Navigation/index.js - About 1 hr to fix

    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

        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

                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

                Function send has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                exports.send = function(subject, template, variables, to, options) {
                  let _this = this;
                
                  if (!options) options = {};
                  options = _.extend({
                Severity: Minor
                Found in modules/application/services/mailer.js - About 45 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 logError has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                exports.logError = (error, req) => {
                
                  if(!error instanceof Error) {
                    if(config.isDev || config.isTest) {
                      throw Error('err object should be instance of error');
                Severity: Minor
                Found in modules/application/controllers/errors.js - About 45 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 getDescription has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                export function getDescription(scrape, cardType, displayType) {
                  const { json: { opengraph, twittercard, head } } = scrape;
                
                  if(cardType === 'twittercard') {
                    if(twittercard['twitter:description']) {
                Severity: Minor
                Found in app/Scrape/helpers.js - About 45 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

                Avoid deeply nested control flow statements.
                Open

                                        if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
                                            to[nextKey] = nextSource[nextKey];
                                        }
                Severity: Major
                Found in app/utils/polyfills.js - About 45 mins to fix

                  Function getTitle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function getTitle(scrape, cardType, displayType) {
                    const { json: { opengraph, twittercard, head } } = scrape;
                    if(cardType === 'twittercard') {
                      if(twittercard['twitter:title']) {
                        return truncateTitle(twittercard['twitter:title'], displayType);
                  Severity: Minor
                  Found in app/Scrape/helpers.js - About 45 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

                  Consider simplifying this complex logical expression.
                  Open

                    if(config.query) {
                  
                      if(!config.query.utm_source && !req.query.utm_source) return;
                      if(!config.query.utm_medium && !req.query.utm_medium) return;
                      if(!config.query.utm_campaign && !req.query.utm_campaign) return;
                  Severity: Major
                  Found in modules/application/services/utm-tracking.js - About 40 mins to fix

                    Function render has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    export default function render(req, res, next, assetManifest, chunkManifest) {
                    Severity: Minor
                    Found in app/Scrape/server.jsx - About 35 mins to fix

                      Function send has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      exports.send = function(subject, template, variables, to, options) {
                      Severity: Minor
                      Found in modules/application/services/mailer.js - About 35 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language