namchey/linkpreview

View on GitHub

Showing 91 of 91 total issues

Function apiErrors has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

exports.apiErrors = (err, req, res, next) => {
  // If the error object doesn't exists
  if(err === undefined) {
    debug('promise breaker');
    return;
Severity: Minor
Found in modules/application/controllers/errors.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 apiErrors has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.apiErrors = (err, req, res, next) => {
  // If the error object doesn't exists
  if(err === undefined) {
    debug('promise breaker');
    return;
Severity: Minor
Found in modules/application/controllers/errors.js - About 2 hrs to fix

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

        {
          /*
           * TC39 categorises proposals for babel in 4 stages
           * Read more http://babeljs.io/docs/usage/experimental/
           */
    Severity: Major
    Found in webpack/production/common-loaders.prod.js and 1 other location - About 1 hr to fix
    webpack/production/common-loaders-server.prod.js on lines 7..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 74.

    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

        {
          /*
           * TC39 categorises proposals for babel in 4 stages
           * Read more http://babeljs.io/docs/usage/experimental/
           */
    Severity: Major
    Found in webpack/production/common-loaders-server.prod.js and 1 other location - About 1 hr to fix
    webpack/production/common-loaders.prod.js on lines 7..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 74.

    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

      componentDidMount() {
        const imageEl = document.getElementById('ogImage');
        isImageSmall(imageEl).then((res) => {
          if(res.isSmall) {
            this.setState({summaryClass: 'summary-column'});
    Severity: Major
    Found in app/Scrape/OpenGraph/index.js and 1 other location - About 1 hr to fix
    app/Scrape/TwitterCard/index.js on lines 22..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 72.

    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

      componentDidMount() {
        const imageEl = document.getElementById('twImage');
        isImageSmall(imageEl).then((res) => {
          if(res.isSmall) {
            this.setState({summaryClass: 'summary-column'});
    Severity: Major
    Found in app/Scrape/TwitterCard/index.js and 1 other location - About 1 hr to fix
    app/Scrape/OpenGraph/index.js on lines 18..26

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

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

    exports.server = (webpackConfig) => {
    
      /*Server*/
      //const serverEntryName = webpackConfig.serverEntryName;
      //const serverEntryFile = webpackConfig.serverEntryFile;
    Severity: Minor
    Found in webpack/production/webpack.base.config.prod.js - About 1 hr to fix

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

          render() {
              const { scrape, isFetching, error, message, authenticated, isCodeLoading, appLoaded } = this.props;
              if(scrape && scrape.json) {
                /*Easy inpection from console*/
                console.log('scrape', scrape);
      Severity: Minor
      Found in app/Scrape/Index/index.js - About 1 hr to fix

        Function getEmbed has 41 lines of code (exceeds 25 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

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

          module.exports = (app) => {
            swig.setFilter('translate', require(path.resolve('./modules/application/services/swig/filter/translate')));
            swig.setFilter('moment', require(path.resolve('./modules/application/services/swig/filter/moment')));
            /*const mustache = require('i18n/node_modules/mustache');
             mustache.escape = function(value) {
          Severity: Minor
          Found in server/express/translations.js - About 1 hr to fix

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

            exports.client = (config = {}) => {
              return [
                //new WebpackMd5Hash(),
                new ManifestPlugin({
                  fileName: 'asset-manifest.json'
            Severity: Minor
            Found in webpack/production/common-plugins.prod.js - About 1 hr to fix

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

              module.exports = (webpackConfig) => {
                  const { assetsPath, publicPath } = webpackConfig;
              
                  return {
                    // The configuration for the server-side rendering
              Severity: Minor
              Found in webpack/development/webpack.config.dev-server.base.js - About 1 hr to fix

                Function client has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.client = (webpackConfig) => {
                
                  const publicPath = webpackConfig.publicPath;
                  const assetsPath = webpackConfig.assetsPath;
                  const vendors = webpackConfig.vendors;
                Severity: Minor
                Found in webpack/production/webpack.base.config.prod.js - About 1 hr to fix

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

                  exports.commonLoaders = (config = {}) => {
                    return [
                      {
                        /*
                         * TC39 categorises proposals for babel in 4 stages
                  Severity: Minor
                  Found in webpack/production/common-loaders-server.prod.js - About 1 hr to fix

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

                    module.exports = (webpackConfig) => {
                        const { assetsPath, publicPath } = webpackConfig;
                        return {
                          // eval - Each module is executed with eval and //@ sourceURL.
                          devtool: 'inline-source-map',
                    Severity: Minor
                    Found in webpack/development/webpack.config.dev-client.base.js - About 1 hr to fix

                      Function logBrowserError has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      exports.logBrowserError = (body = {}, req) => {
                        if (config.isProd) {
                          const fileLogContents = { ...body };
                      
                          //delete screenshot field for loggin in file
                      Severity: Minor
                      Found in modules/application/controllers/errors.js - About 1 hr to fix

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

                        exports.init =  (db) => {
                        
                          // Initialize express app
                          const app = express();
                        
                        
                        Severity: Minor
                        Found in server/express/index.js - About 1 hr to fix

                          Function logError has 30 lines of code (exceeds 25 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 1 hr to fix

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

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

                              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
                                Severity
                                Category
                                Status
                                Source
                                Language