WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

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

const addTagPromise = async (courseId, tag) => {
  const response = await request(`/courses/${courseId}/tag.json`, {
    method: 'POST',
    body: JSON.stringify({ tag: { tag } })
  });
Severity: Major
Found in app/assets/javascripts/actions/tag_actions.js and 3 other locations - About 4 hrs to fix
app/assets/javascripts/actions/campaign_actions.js on lines 32..44
app/assets/javascripts/actions/campaign_actions.js on lines 59..71
app/assets/javascripts/actions/tag_actions.js on lines 73..85

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

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

const removeCampaignsPromise = async (courseId, campaignId) => {
  const response = await request(`/courses/${courseId}/campaign.json`, {
    method: 'DELETE',
    body: JSON.stringify({ campaign: { title: campaignId } })
  });
Severity: Major
Found in app/assets/javascripts/actions/campaign_actions.js and 3 other locations - About 4 hrs to fix
app/assets/javascripts/actions/campaign_actions.js on lines 59..71
app/assets/javascripts/actions/tag_actions.js on lines 46..58
app/assets/javascripts/actions/tag_actions.js on lines 73..85

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

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 render has 116 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const spacer = this.props.spacer || ': ';
    let label;
    let timeLabel;
    let currentMonth;
Severity: Major
Found in app/assets/javascripts/components/common/date_picker.jsx - About 4 hrs to fix

    Function Feedback has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    const Feedback = ({ assignment, username, current_user }) => {
      const [show, setShow] = useState(false);
      const [fetched, setFetched] = useState(false);
      const [feedbackSent, setFeedbackSent] = useState(false);
      const [feedbackInput, setFeedbackInput] = useState('');
    Severity: Minor
    Found in app/assets/javascripts/components/common/feedback.jsx - 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 render has 113 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      render() {
        const { course, current_user } = this.props;
    
        if (course.cloned_status === 1 || course.cloned_status === 3) {
          return (
    Severity: Major
    Found in app/assets/javascripts/components/overview/overview_handler.jsx - About 4 hrs to fix

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

        const campaignList = campaigns.map((campaign) => {
          const removeButton = (
            <button className="button border plus" aria-label="Remove campaign" onClick={() => removeCampaignHandler(campaign.title)}>-</button>
          );
          return (
      app/assets/javascripts/components/overview/tag_editable.jsx on lines 64..73

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

      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

        const tagList = tags.map((tag) => {
          const removeButton = (
            <button className="button border plus" aria-label="Remove tag" onClick={() => removeTagHandler(tag.tag)}>-</button>
          );
          return (
      Severity: Major
      Found in app/assets/javascripts/components/overview/tag_editable.jsx and 1 other location - About 4 hrs to fix
      app/assets/javascripts/components/overview/campaign_editable.jsx on lines 79..88

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

      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

        programHelpUser() {
          if (this.props.programManagers && this.props.programManagers.length > 0) {
            return this.props.programManagers[0];
          } else if (this.props.contentExperts && this.props.contentExperts.length > 0) {
            return this.props.contentExperts[0];
      Severity: Major
      Found in app/assets/javascripts/components/common/get_help_button.jsx and 1 other location - About 4 hrs to fix
      app/assets/javascripts/components/common/get_help_button.jsx on lines 78..85

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

      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

        wikipediaHelpUser() {
          if (this.props.contentExperts && this.props.contentExperts.length > 0) {
            return this.props.contentExperts[0];
          } else if (this.props.programManagers && this.props.programManagers.length > 0) {
            return this.props.programManagers[0];
      Severity: Major
      Found in app/assets/javascripts/components/common/get_help_button.jsx and 1 other location - About 4 hrs to fix
      app/assets/javascripts/components/common/get_help_button.jsx on lines 87..94

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

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

      const Panel = (props) => {
        const persistState = () => {
            const step = props.step.toLowerCase().split(' ').slice(0, 2);
            step[1] = +step[1] + 1; // Keeping the step in line with the UI
            window.history.pushState(
      Severity: Minor
      Found in app/assets/javascripts/components/wizard/panel.jsx - 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 InputHOC has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

      const InputHOC = (Component) => {
        const validatingComponent = createReactClass({
          displayName: `Input${Component.displayName}`,
      
          // value passed is HOC's state value
      Severity: Minor
      Found in app/assets/javascripts/components/high_order/input_hoc.jsx - 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

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

      const CoursesTaughtGraph = (props) => {
        useEffect(() => {
          renderGraph(props.statsData, props.graphWidth, props.graphHeight, props.courseStringPrefix);
        }, []);
          return (
      app/assets/javascripts/components/user_profiles/graphs/as_instructor_graphs/students_taught_graph.jsx on lines 102..112

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

      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

      const StudentsTaughtGraph = (props) => {
        useEffect(() => {
          renderGraph(props.statsData, props.graphWidth, props.graphHeight, props.courseStringPrefix);
        }, []);
          return (
      app/assets/javascripts/components/user_profiles/graphs/as_instructor_graphs/courses_taught_graph.jsx on lines 104..114

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

      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

      const HEADERS = [
        { title: I18n.t('recent_activity.article_title'), key: 'title' },
        { title: I18n.t('recent_activity.revision_score'), key: 'revision_score', style: { width: 180 } },
        { title: I18n.t('recent_activity.revision_author'), key: 'username', style: { minWidth: 142 } },
        { title: I18n.t('recent_activity.revision_datetime'), key: 'datetime', style: { width: 200 } }
      app/assets/javascripts/components/activity/recent_edits_handler.jsx on lines 9..14

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

      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

      const HEADERS = [
        { title: I18n.t('recent_activity.article_title'), key: 'title' },
        { title: I18n.t('recent_activity.revision_score'), key: 'revision_score', style: { width: 180 } },
        { title: I18n.t('recent_activity.revision_author'), key: 'username', style: { minWidth: 142 } },
        { title: I18n.t('recent_activity.revision_datetime'), key: 'datetime', style: { width: 200 } },
      app/assets/javascripts/components/activity/did_you_know_handler.jsx on lines 9..14

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

      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 Wp10Graph has 107 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const Wp10Graph = (props) => {
        useEffect(() => {
          renderGraph();
        }, []);
      
      
      Severity: Major
      Found in app/assets/javascripts/components/articles/wp10_graph.jsx - About 4 hrs to fix

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

          _handleMoveBlock(moveUp, blockId) {
            for (let i = 0; i < this.props.weeks.length; i += 1) {
              const week = this.props.weeks[i];
              const blocks = this.getBlocksInWeek(week.id);
              for (let j = 0; j < blocks.length; j += 1) {
        Severity: Minor
        Found in app/assets/javascripts/components/timeline/timeline.jsx - 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 render has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

          render() {
            const spacer = this.props.spacer || ': ';
            let label;
            let timeLabel;
            let currentMonth;
        Severity: Minor
        Found in app/assets/javascripts/components/common/date_picker.jsx - 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 PagePileScoping has 105 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const PagePileScoping = () => {
          const [inputValue, setInputValue] = useState('');
          const pagePileIds = useSelector(state => state.scopingMethods.pagepile.ids);
        
          const dispatch = useDispatch();

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

          const updateSiteNoticePromise = async (siteNotice) => {
            const body = {
              site_notice: siteNotice,
            };
            const response = await request('/settings/update_site_notice', {
          Severity: Major
          Found in app/assets/javascripts/actions/settings_actions.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/actions/settings_actions.js on lines 436..451

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

          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

          Severity
          Category
          Status
          Source
          Language