namchey/linkpreview

View on GitHub

Showing 91 of 91 total issues

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

      {message ?<div className={cx('alert', 'alert-success')}>
        <b>{message}</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 18..21
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

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

      {warning ? <div className={cx('alert', 'alert-warning')}>
        <b>{warning}</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 18..21
app/components/Message/index.js on lines 22..25

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

      {normal ? <div className={cx('alert', 'alert-normal')}>
        <b>{normal}</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 18..21
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

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

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

    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

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

    function makeAppRequest(method, data, api='/api/statistics') {
      if(data && method === 'get') {
        return axios[method](api, {params: data});
      }
      return axios[method](api, data);
    Severity: Minor
    Found in app/actions/app.js and 1 other location - About 40 mins to fix
    app/Scrape/actions.js on lines 10..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 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

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

    function makeScrapeRequest(method, data, api='/api/v1/scrape') {
      if(data && method === 'get') {
        return axios[method](api, {params: data});
      }
      return axios[method](api, data);    
    Severity: Minor
    Found in app/Scrape/actions.js and 1 other location - About 40 mins to fix
    app/actions/app.js on lines 10..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 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

    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

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

      const Message = ({message, error, normal, warning, isFixed, className, removable, dispatch, action}) => {
      
        const closeButton = removable && <span className={cx('btn-close', 'pull-right')} onClick = {(e) => {dispatch(action())}}>X</span>;
      
        return (
      Severity: Minor
      Found in app/components/Message/index.js and 1 other location - About 40 mins to fix
      app/Scrape/server.jsx on lines 66..74

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

      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

      function renderContent({res, componentHTML, initialState, headconfig, chunkManifest, styles, scripts, metaProperties, status}) {
        const output = renderFullPage({componentHTML, initialState, head: {
          title: headconfig.title,
          meta: headconfig.meta,
          link: headconfig.link,
      Severity: Minor
      Found in app/Scrape/server.jsx and 1 other location - About 40 mins to fix
      app/components/Message/index.js on lines 8..32

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

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

        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

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

            getDescription() {
              const { opengraph, scrape } = this.props;
          
              return getDescription(scrape, 'opengraph', this.state.summaryClass);
          
          
          Severity: Minor
          Found in app/Scrape/OpenGraph/index.js and 1 other location - About 35 mins to fix
          app/Scrape/OpenGraph/index.js on lines 28..33

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

          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

            getTitle() {
              const { opengraph, scrape } = this.props;
          
              return getTitle(scrape, 'opengraph', this.state.summaryClass);
          
          
          Severity: Minor
          Found in app/Scrape/OpenGraph/index.js and 1 other location - About 35 mins to fix
          app/Scrape/OpenGraph/index.js on lines 36..41

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

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

          export default function preRenderMiddleware(dispatch, components, params, req) {
            let promises = [];
            try {
              const needs = components.reduce( (prev, current) => {
                if(!current) {
          Severity: Minor
          Found in app/middlewares/preRenderMiddleware.js - About 35 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 indexView has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          exports.indexView = (req, res, next) => {
              let compiled_app_module_path = path.resolve('public', 'assets', 'scrape.server.js');
              if(config.isProd || config.isCI) {
                  compiled_app_module_path = path.resolve('public', 'server-assets', 'scrape.server.js');
              }
          Severity: Minor
          Found in modules/scrape/v1/controllers/index.js - About 35 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 configureStore has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function configureStore(initialState, history) {
            let middleware = [noopMiddleware, thunk, promiseMiddleware ];
            // Installs hooks that always keep react-router and redux
            // store in sync
            const reactRouterReduxMiddleware = routerMiddleware(history);
          Severity: Minor
          Found in app/Scrape/store/configureStore.js - About 35 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

          Severity
          Category
          Status
          Source
          Language