WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

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

ButtonNavigation.propTypes = {
  active: PropTypes.bool.isRequired,
  assignment: PropTypes.object.isRequired,
  course: PropTypes.object.isRequired,
  index: PropTypes.number.isRequired,
app/assets/javascripts/components/common/ArticleViewer/components/BadWorkAlert/SubmitIssuePanel.jsx on lines 41..46
app/assets/javascripts/components/common/OverviewStats/overview_stats_tab.jsx on lines 15..20
app/assets/javascripts/components/overview/clone_course_button.jsx on lines 8..13

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

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

CloneCourseButton.propTypes = {
  courseId: PropTypes.number.isRequired,
  cloneCourse: PropTypes.func.isRequired,
  initiateConfirm: PropTypes.func.isRequired,
  updateCourse: PropTypes.func.isRequired
app/assets/javascripts/components/common/ArticleViewer/components/BadWorkAlert/SubmitIssuePanel.jsx on lines 41..46
app/assets/javascripts/components/common/OverviewStats/overview_stats_tab.jsx on lines 15..20
app/assets/javascripts/components/overview/my_articles/components/Categories/List/Assignment/ProgressTracker/Step/ButtonNavigation.jsx on lines 54..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 64.

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

SubmitIssuePanel.propTypes = {
  handleChange: PropTypes.func.isRequired,
  handleSubmit: PropTypes.func.isRequired,
  message: PropTypes.string.isRequired,
  project: PropTypes.string.isRequired
app/assets/javascripts/components/common/OverviewStats/overview_stats_tab.jsx on lines 15..20
app/assets/javascripts/components/overview/clone_course_button.jsx on lines 8..13
app/assets/javascripts/components/overview/my_articles/components/Categories/List/Assignment/ProgressTracker/Step/ButtonNavigation.jsx on lines 54..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 64.

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 (getFiltered(users, { id: currentUser.id, role: INSTRUCTOR_ROLE })[0]) {
      roles.isInstructor = true;
      roles.isAdvancedRole = true;
      roles.isEnrolled = true;
    }
Severity: Major
Found in app/assets/javascripts/utils/user_utils.js and 1 other location - About 1 hr to fix
app/assets/javascripts/utils/user_utils.js on lines 26..30

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

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 (getFiltered(users, { id: currentUser.id, role: STAFF_ROLE })[0]) {
      roles.isStaff = true;
      roles.isAdvancedRole = true;
      roles.isEnrolled = true;
    }
Severity: Major
Found in app/assets/javascripts/utils/user_utils.js and 1 other location - About 1 hr to fix
app/assets/javascripts/utils/user_utils.js on lines 13..17

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

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

        <Routes>
          <Route path="ores_plot" element={<CampaignOresPlot />} />
          <Route path="alerts" element={<CampaignAlerts />} />
        </Routes>
Severity: Major
Found in app/assets/javascripts/components/campaign/campaign.jsx and 1 other location - About 1 hr to fix
app/assets/javascripts/training/components/training_app.jsx on lines 10..13

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

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

    <Routes>
      <Route path=":library_id/:module_id" element={<TrainingModuleHandler />} />
      <Route path=":library_id/:module_id/:slide_id" element={<TrainingSlideHandler />} />
    </Routes>
Severity: Major
Found in app/assets/javascripts/training/components/training_app.jsx and 1 other location - About 1 hr to fix
app/assets/javascripts/components/campaign/campaign.jsx on lines 46..49

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

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

const fetchPageRevisionScore = async (revids, wiki, dispatch) => {
    const query = pageRevisionScoreQueryGenerator(map(revids, (revid) => {
      return revid.revisions[0].revid;
    }), wiki.project);

Severity: Minor
Found in app/assets/javascripts/actions/article_finder_action.js - About 1 hr to fix

    Function scrollTo has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        scrollTo(name, scrollBox) {
            this.bump = false;
            const paragraphs = this.scrollObject[name].filteredParagraphs;
            const length = paragraphs.length;
            this.nextPosition = paragraphs[this.scrollObject[name].index].coordinates;

      Function SearchableCourseList has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const SearchableCourseList = () => {
        const [searchParams, setSearchParams] = useSearchParams();
        const { results, loaded, sort } = useSelector(state => state.course_search_results);
        const dispatch = useDispatch();
        const searchRef = useRef();
      Severity: Minor
      Found in app/assets/javascripts/components/course/searchable_course_list.jsx - About 1 hr to fix

        Function PopoverExpandable has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const PopoverExpandable = function (Component) {
          const wrappedComponent = createReactClass({
            displayName: 'PopoverExpandable',
        
            statics: {
        Severity: Minor
        Found in app/assets/javascripts/components/high_order/popover_expandable.jsx - About 1 hr to fix

          Function InlineUsers has 36 lines of code (exceeds 25 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

            Function popover has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              popover() {
                const PopoverExample = createReactClass({
                  getInitialState() {
                    return {
                      open: false
            Severity: Minor
            Found in app/assets/javascripts/styleguide/styleguide.jsx - About 1 hr to fix

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

                  scrollTo(name, scrollBox) {
                      this.bump = false;
                      const paragraphs = this.scrollObject[name].filteredParagraphs;
                      const length = paragraphs.length;
                      this.nextPosition = paragraphs[this.scrollObject[name].index].coordinates;

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

              export const sortByKey = (models, sortKey, previousKey = null, desc = false, absolute = false, refresh = false) => {
                const sameKey = sortKey === previousKey;
                let newKey;
                if (sameKey) {
                  newKey = null;
              Severity: Minor
              Found in app/assets/javascripts/utils/model_utils.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 getFilteredArticleFinder has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                [getArticleFinderState], (articleFinder) => {
                  return pickBy(articleFinder.articles, (article) => {
                    const language = articleFinder.home_wiki.language;
                    const project = articleFinder.home_wiki.project;
                    if (article.grade && !includes(Object.keys(PageAssessmentGrades[project][language]), article.grade)) {
              Severity: Minor
              Found in app/assets/javascripts/selectors/index.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 fetchRevisionsFromUsers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              export const fetchRevisionsFromUsers = async (course, users, days, last_date, filter) => {
                const usernames = users.map(user => user.username);
              
                let revisions = [];
                const wikiPromises = [];
              Severity: Minor
              Found in app/assets/javascripts/utils/mediawiki_revisions_utils.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 fetchAll has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              const fetchAll = async (API_URL, params, continue_str) => {
                const allData = [];
                let continueToken;
                let hasMore = true;
                while (hasMore) {
              Severity: Minor
              Found in app/assets/javascripts/utils/mediawiki_revisions_utils.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 ActiveCourseList has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              const ActiveCourseList = ({ defaultCampaignOnly = true }) => {
                const { isLoaded, courses, sort } = useSelector(state => state.active_courses);
                const dispatch = useDispatch();
              
                useEffect(() => {
              Severity: Minor
              Found in app/assets/javascripts/components/course/active_course_list.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 userRoles has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                userRoles(currentUser, users) {
                  // Role values correspond to the CoursesUsers roles defined
                  const roles = {};
                  if (!currentUser) { return roles; }
                  if (getFiltered(users, { id: currentUser.id, role: STUDENT_ROLE })[0]) {
              Severity: Minor
              Found in app/assets/javascripts/utils/user_utils.js - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language