pesto-students/batch-11-relayer

View on GitHub

Showing 13 of 49 total issues

Function SlackTriggerDispatcher has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

const SlackTriggerDispatcher = async (relays, event, authedUsers) => {
  for (const relay of relays) {
    for (const participantApp of relay.participantApps) {
      if (participantApp.eventType === 'Trigger') {
        const authDetails = await getCredentialsFromAuthedApps(participantApp.authentication);
Severity: Minor
Found in server/thirdparty/controller/SlackTriggerDispatcher.js - About 3 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 RelaySelection has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

const RelaySelection = ({ appData }) => {
  const { relayData, storeRelayData } = useRelays();
  const appNames = appData.map((app) => app.AppName);
  appNames.unshift('Select');
  const [triggers, setTriggers] = useState({ slackTriggers: [], githubTriggers: [] });
Severity: Minor
Found in client/src/components/Dashboard/CreateNewRelay/RelaySelection.js - About 3 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 performGithubActionOnSlackTrigger has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const performGithubActionOnSlackTrigger = async (event, authenticatedUser) => {
  const action = convertArgsStringToObject(event.text)._[0].split(':')[1];
  const authorizedSlackApp = await AuthorizedApps.findOne({ appName: 'Slack', 'credentials.slackUserId': authenticatedUser[0] }).lean();
  const authorizedGithubApp = await AuthorizedApps.findOne({ appName: 'Github', userId: authorizedSlackApp.userId }).lean();
  const messageConfig = { channel: event.channel, token: authorizedSlackApp.authToken };
Severity: Major
Found in server/thirdparty/controller/githubHandler.js - About 2 hrs to fix

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

    const TaskHistory = () => {
      const [taskHistory, setTaskHistory] = useState([]);
      const [relays, setRelays] = useState([]);
    
      const getTaskHistory = async () => {
    Severity: Minor
    Found in client/src/components/Dashboard/TaskHistory/TaskHistory.js - About 1 hr to fix

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

      const SlackActionPerformer = async (relayId, action, triggerEvent) => {
        for (const slackEvent of IntegrationConfig.Slack.Events) {
          if (slackEvent.EventName === action.event) {
            const authDetails = await getCredentialsFromAuthedApps(action.authentication);
            const token = authDetails.authToken;
      Severity: Minor
      Found in server/thirdparty/controller/SlackActionPerformer.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 Form has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const Form = (props) => {
        const refs = [];
        const onSubmit = (event) => {
          props.onClick(event, ...refs);
          props.history.push('/dashboard');
      Severity: Minor
      Found in client/src/components/common/Form.js - About 1 hr to fix

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

        const SlackActionPerformer = async (relayId, action, triggerEvent) => {
          for (const slackEvent of IntegrationConfig.Slack.Events) {
            if (slackEvent.EventName === action.event) {
              const authDetails = await getCredentialsFromAuthedApps(action.authentication);
              const token = authDetails.authToken;
        Severity: Minor
        Found in server/thirdparty/controller/SlackActionPerformer.js - About 1 hr to fix

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

          const createPages = (...args) => {
            const [handlePageNav, pagesPerList, pageList, currentPage, pages] = args;
            const items = [];
            const children = '...';
            [1, 2, 3].forEach((number) => {
          Severity: Minor
          Found in client/src/components/common/Pagination/pageUtils.js - About 1 hr to fix

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

              const HeaderRigth = () => {
                if (auth.isAuthenticated) {
                  return (
                    <UncontrolledDropdown>
                      <DropdownToggle caret color="primary" className="mr-5">
            Severity: Minor
            Found in client/src/components/common/Header.js - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                        if (inputMatch) {
                          ActionPerformer.ActionPerformer(relay, event);
                        }
              Severity: Major
              Found in server/thirdparty/controller/SlackTriggerDispatcher.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                          for (const [inputName, inputValue] of participantApp.inputs) {
                            if (event[inputName] !== inputValue) {
                              inputMatch = false;
                            }
                          }
                Severity: Major
                Found in server/thirdparty/controller/SlackTriggerDispatcher.js - About 45 mins to fix

                  Function CreateConfiguration has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const CreateConfiguration = ({
                    apps, trigger, action, triggerAccount, actionAccount,
                  }) => {
                    const { relayData, storeRelayData } = useRelays();
                    const [triggerFields, setTriggerFields] = useState({});

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

                  const getFromConfig = async (req) => {
                    const {
                      AppName,
                      EventName,
                      DetailName,
                  Severity: Minor
                  Found in server/thirdparty/controller/SlackDataFetchController.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