glitch-soc/mastodon

View on GitHub

Showing 1,287 of 4,903 total issues

Avoid too many return statements within this function.
Open

    return state.setIn([action.payload.id, 'following'], true);
Severity: Major
Found in app/javascript/mastodon/reducers/relationships.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

      else return state;
    Severity: Major
    Found in app/javascript/mastodon/reducers/accounts.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return state.setIn([action.payload.id, 'following'], false);
      Severity: Major
      Found in app/javascript/mastodon/reducers/relationships.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          else return state;
        Severity: Major
        Found in app/javascript/mastodon/reducers/modal.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return setDomainBlocking(state, action.payload.accounts, false);
          Severity: Major
          Found in app/javascript/mastodon/reducers/relationships.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              else return state;
            Severity: Major
            Found in app/javascript/mastodon/reducers/relationships.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return normalizeRelationship(state, action.payload.relationship);
              Severity: Major
              Found in app/javascript/mastodon/reducers/relationships.ts - About 30 mins to fix

                Function createFilterStatus has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                export const createFilterStatus = (params, onSuccess, onFail) => (dispatch) => {
                  dispatch(createFilterStatusRequest());
                
                  api().post(`/api/v2/filters/${params.filter_id}/statuses`, params).then(response => {
                    dispatch(createFilterStatusSuccess(response.data));
                Severity: Minor
                Found in app/javascript/flavours/glitch/actions/filters.js - About 25 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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  render () {
                    const { poll, intl } = this.props;
                    const { revealed, expired } = this.state;
                
                    if (!poll) {
                Severity: Minor
                Found in app/javascript/flavours/glitch/components/poll.jsx - About 25 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 shouldComponentUpdate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  shouldComponentUpdate (nextProps, nextState) {
                    const isUnrendered = !this.state.isIntersecting && (this.state.isHidden || this.props.cachedHeight);
                    const willBeUnrendered = !nextState.isIntersecting && (nextState.isHidden || nextProps.cachedHeight);
                    if (!!isUnrendered !== !!willBeUnrendered) {
                      // If we're going from rendered to unrendered (or vice versa) then update

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

                  render () {
                    const { status, width, height, visible } = this.props;
                    const mediaAttachments = status.get('media_attachments');
                    const language = status.getIn(['language', 'translation']) || status.get('language') || this.props.lang;
                
                
                Severity: Minor
                Found in app/javascript/flavours/glitch/components/media_attachments.jsx - About 25 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 textForScreenReader has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                export const textForScreenReader = (intl, status, rebloggedByText = false, expanded = false) => {
                  const displayName = status.getIn(['account', 'display_name']);
                
                  const spoilerText = status.getIn(['translation', 'spoiler_text']) || status.get('spoiler_text');
                  const contentHtml = status.getIn(['translation', 'contentHtml']) || status.get('contentHtml');
                Severity: Minor
                Found in app/javascript/flavours/glitch/components/status.jsx - About 25 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 focusChild has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                const focusChild = (node, index, alignTop) => {
                  const element = node.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
                
                  if (element) {
                    if (alignTop && node.scrollTop > element.offsetTop) {

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

                  _selectChild (index, align_top) {
                    const container = this.node.node;
                    const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
                
                    if (element) {
                Severity: Minor
                Found in app/javascript/flavours/glitch/components/status_list.jsx - About 25 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 getSnapshotBeforeUpdate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  getSnapshotBeforeUpdate (prevProps) {
                    const someItemInserted = Children.count(prevProps.children) > 0 &&
                      Children.count(prevProps.children) < Children.count(this.props.children) &&
                      this.getFirstChildKey(prevProps) !== this.getFirstChildKey(this.props);
                    const pendingChanged = (prevProps.numPending > 0) !== (this.props.numPending > 0);
                Severity: Minor
                Found in app/javascript/flavours/glitch/components/scrollable_list.jsx - About 25 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 resizeFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                const resizeFile = (inputFile) => new Promise((resolve) => {
                  if (!inputFile.type.match(/image.*/) || inputFile.type === 'image/gif') {
                    resolve(inputFile);
                    return;
                  }
                Severity: Minor
                Found in app/javascript/flavours/glitch/utils/resize_image.js - About 25 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 textAtCursorMatchesToken has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                const textAtCursorMatchesToken = (str, caretPosition, searchTokens) => {
                  let word;
                
                  let left  = str.slice(0, caretPosition).search(/\S+$/);
                  let right = str.slice(caretPosition).search(/\s/);
                Severity: Minor
                Found in app/javascript/flavours/glitch/components/autosuggest_input.jsx - About 25 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 createFilter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                export const createFilter = (params, onSuccess, onFail) => (dispatch) => {
                  dispatch(createFilterRequest());
                
                  api().post('/api/v2/filters', params).then(response => {
                    dispatch(createFilterSuccess(response.data));
                Severity: Minor
                Found in app/javascript/flavours/glitch/actions/filters.js - About 25 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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  render () {
                    const { emoji } = this.props;
                    let url;
                
                    if (emoji.custom) {
                Severity: Minor
                Found in app/javascript/flavours/glitch/components/autosuggest_emoji.jsx - About 25 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 submitReport has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                export const submitReport = (params, onSuccess, onFail) => (dispatch) => {
                  dispatch(submitReportRequest());
                
                  api().post('/api/v1/reports', params).then(response => {
                    dispatch(submitReportSuccess(response.data));
                Severity: Minor
                Found in app/javascript/flavours/glitch/actions/reports.js - About 25 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