csblogs/feed-downloader

View on GitHub

Showing 6 of 8 total issues

Function extractRSSPostImage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export function extractRSSPostImage(post) {
  let imageURI = null;
  if (post['media:content']) {
    const validMediaContentImageURLs = post['media:content']
                                        .map(media => media.$)
Severity: Minor
Found in src/feed-parser/extract-post-image.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 httpRequestIfModifiedSince has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function httpRequestIfModifiedSince(uri, dateTime) {
  return new Promise((resolve, reject) => {
    if (!dateTime || check.instance(dateTime, Date.prototype)) {
      reject(new Error('Valid DateTime required'));
    }
Severity: Minor
Found in src/http/if-modified-since-request.js - About 1 hr to fix

    Function formatNewBlogsNotification has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    function formatNewBlogsNotification(usersToNewPosts) {
      if (!check.array(usersToNewPosts) || usersToNewPosts.length === 0) {
        throw new Error('Valid array of users with new posts required');
      }
    
    
    Severity: Minor
    Found in src/notifications/notify-of-new-blogs.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 getUsersNewPosts has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function getUsersNewPosts(user) {
      return new Promise((resolve, reject) => {
        let lastModifiedDate = null;
    
        requestUserFeed(user)
    Severity: Minor
    Found in src/aggregator/get-users-new-posts.js - About 1 hr to fix

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

      export default function aggregate() {
        initDbLogger(log);
      
        return new Promise((resolve, reject) => {
          database.sync()
      Severity: Minor
      Found in src/aggregator/index.js - About 1 hr to fix

        Function formatNewBlogsNotification has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function formatNewBlogsNotification(usersToNewPosts) {
          if (!check.array(usersToNewPosts) || usersToNewPosts.length === 0) {
            throw new Error('Valid array of users with new posts required');
          }
        
        
        Severity: Minor
        Found in src/notifications/notify-of-new-blogs.js - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language