WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

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

    if (!programManager.already_selected) {
      const programManagerUserObject = {
        username: programManager.username,
        role: STAFF_ROLE,
        role_description: null,
app/assets/javascripts/components/course/course_approval.jsx on lines 135..143

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

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

    if (!wikiExpert.already_selected) {
      const wikiExpertUserObject = {
        username: wikiExpert.username,
        role: STAFF_ROLE,
        role_description: null,
app/assets/javascripts/components/course/course_approval.jsx on lines 124..132

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

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

    if (urlParts && urlParts.length > 3) {
      const title = decodeURIComponent(urlParts[3]).replace(/_/g, ' ');
      const project = urlParts[2];
      const language = urlParts[1];
      return {
Severity: Major
Found in app/assets/javascripts/utils/course_utils.js and 1 other location - About 1 hr to fix
app/assets/javascripts/utils/course_utils.js on lines 96..106

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

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

const TrainingModulesViewMode = (props) => {
    const block = props.block;
    const modules = [];
    const length = block.training_modules.length;

    Function TrainingModuleHandler has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const TrainingModuleHandler = (props) => {
      useEffect(() => {
        const moduleId = document.getElementById('react_root').getAttribute('data-module-id');
        props.fetchTrainingModule({ module_id: moduleId });
      }, []);

      Function articleFinder has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function articleFinder(state = initialState, action) {
        switch (action.type) {
          case UPDATE_FINDER_FIELD: {
            const newState = { ...state };
            newState[action.data.key] = action.data.value;
      Severity: Minor
      Found in app/assets/javascripts/reducers/article_finder.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 render has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        render() {
          let content;
          let faqLink;
      
          let wikipediaHelpButton;
      Severity: Minor
      Found in app/assets/javascripts/components/common/get_help_button.jsx - 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 PetScanScoping has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      const PetScanScoping = () => {
        const [inputValue, setInputValue] = React.useState('');
        const petscanIDs = useSelector(state => state.scopingMethods.petscan.psids);
        const dispatch = useDispatch();
        const home_wiki = useSelector(state => state.course.home_wiki);

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

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

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

      const CourseOresPlot = ({ course }) => {
        const [show, setShow] = useState(false);
        const [refreshedData, setRefreshedData] = useState(null);
        const [loading, setLoading] = useState(true);
        const [refresh, setRefresh] = useState(false);
      Severity: Minor
      Found in app/assets/javascripts/components/articles/course_ores_plot.jsx - 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

      Method create_alerts has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def create_alerts
          @courses.each do |course|
            next unless course.type == 'ClassroomProgramCourse'
            next unless course.approved? # No alerts needed for unapproved courses
            next if Alert.exists?(course_id: course.id, type: 'UntrainedStudentsAlert')
      Severity: Minor
      Found in lib/alerts/untrained_students_alert_manager.rb - 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 InlineUsers has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      const InlineUsers = (props) => {
        const lastUserIndex = props.users.length - 1;
        let userList = props.users.map((user, index) => {
          let extraInfo = '';
          const link = `/users/${user.username}`; // User profile page
      Severity: Minor
      Found in app/assets/javascripts/components/overview/inline_users.jsx - 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

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

      const Article = ({ article, index, course, fetchArticleDetails, updateArticleTrackedStatus, articleDetails, wikidataLabel,
        showOnMount, setSelectedIndex, lastIndex, selectedIndex, pageLogsMessage, deletedMessage, current_user }) => {
        const [tracked, setTracked] = useState(article.tracked);
      
        const fetchMissingArticleDetails = () => {
      Severity: Major
      Found in app/assets/javascripts/components/articles/article.jsx and 1 other location - About 1 hr to fix
      app/assets/javascripts/components/students/components/Articles/SelectedStudent/SelectedStudent.jsx on lines 19..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 73.

      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

            axes: [
              {
                orient: 'bottom',
                scale: 'x',
                grid: true,
      app/assets/javascripts/components/articles/wp10_graph.jsx on lines 40..56

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

      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

        if (!userLoggedIn()) {
          loginWarning = (
            <div className="training__slide__notification" key="not_logged_in">
              <div className="container">
                <p>{I18n.t('training.logged_out')}</p>
      app/assets/javascripts/training/components/training_slide_handler.jsx on lines 181..189

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

      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

      export const SelectedStudent = ({
        groupedArticles, assignments, course, current_user, fetchArticleDetails,
        hasExercisesOrTrainings, openKey,
        sort, sortUsers, trainingStatus, wikidataLabels, userRevisions,
        students, articlesUrl
      app/assets/javascripts/components/articles/article.jsx on lines 11..135

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

      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

          if (training.completed === false) {
            pendingWarning = (
              <div className="training__slide__notification" key="pending">
                <div className="container">
                  <p>{I18n.t('training.wait')}</p>
      app/assets/javascripts/training/components/training_slide_handler.jsx on lines 193..201

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

      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

            axes: [
              {
                orient: 'bottom',
                scale: 'x',
                grid: true,
      Severity: Major
      Found in app/assets/javascripts/components/articles/wp10_graph.jsx and 1 other location - About 1 hr to fix
      app/assets/javascripts/components/articles/edit_size_graph.jsx on lines 43..59

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

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

      export const downgradeAdmin = username => (dispatch) => {
        // remove a user's admin status
        // username: user's username
        dispatch({
          type: REVOKING_ADMIN,
      Severity: Minor
      Found in app/assets/javascripts/actions/settings_actions.js - About 1 hr to fix

        Function fetchCourseScopedRevisions has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const fetchCourseScopedRevisions = (course, limit) => async (dispatch, getState) => {
          const state = getState();
          const users = state.users.users.filter(user => user.role === STUDENT_ROLE);
        
          dispatch({ type: COURSE_SCOPED_REVISIONS_LOADING });
        Severity: Minor
        Found in app/assets/javascripts/actions/revisions_actions.js - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language