lgaticaq/hubot-travis-ci-hook

View on GitHub

Showing 4 of 9 total issues

Function getAttachments has 151 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const getAttachments = (robot, req) => {
  return new Promise((resolve, reject) => {
    try {
      let hours, minutes, seconds
      const signature = req.get('Signature') || ''
Severity: Major
Found in src/script.js - About 6 hrs to fix

    Function getAttachments has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    const getAttachments = (robot, req) => {
      return new Promise((resolve, reject) => {
        try {
          let hours, minutes, seconds
          const signature = req.get('Signature') || ''
    Severity: Minor
    Found in src/script.js - About 4 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 exports has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = robot => {
      robot.router.post('/travis-ci/:room', (req, res) => {
        const channel = req.params.room
        getAttachments(robot, req)
          .then(results => {
    Severity: Minor
    Found in src/script.js - About 1 hr to fix

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

      const request = (robot, uri) => {
        return new Promise((resolve, reject) => {
          robot
            .http(uri)
            .header('User-Agent', robot.name)
      Severity: Minor
      Found in src/script.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

      Severity
      Category
      Status
      Source
      Language