WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 1,672 of 1,672 total issues

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

  const options = [
    { value: '', label: '— select one —' },
    { value: 'In-person', label: 'In-person' },
    { value: 'Online synchronous', label: 'Online synchronous' },
    { value: 'Online asynchronous', label: 'Online asynchronous' },
app/assets/javascripts/components/resources/templates.jsx on lines 16..22
app/assets/javascripts/components/tickets/search_type_selector.jsx on lines 6..12

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

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

  it('should create an action to remove a news notification', () => {
    const notification = { id: 1, message: 'Remove this notification' };
    const expectedAction = {
      type: REMOVE_NEWS_NOTIFICATION,
      notification
Severity: Major
Found in test/actions/news_notification.spec.js and 1 other location - About 1 hr to fix
test/actions/news_notification.spec.js on lines 6..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 68.

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

export const Notifications = () => {
  const dispatch = useDispatch();
  const notifications = useSelector(state => state.newsNotifications);

  const _handleClose = (notification) => {

    Function Notifications has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const Notifications = () => {
      const dispatch = useDispatch();
      const notifications = useSelector(state => state.notifications);
    
      const _handleClose = (notification) => {
    Severity: Minor
    Found in app/assets/javascripts/components/common/notifications.jsx - About 1 hr to fix

      Function saveTimeline has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async saveTimeline(courseId, data) {
          const cleanObject = object => {
            if (object.is_new) {
              delete object.id;
              delete object.is_new;
      Severity: Minor
      Found in app/assets/javascripts/utils/api.js - About 1 hr to fix

        Function campaigns has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function campaigns(state = initialState, action) {
          switch (action.type) {
            case ADD_CAMPAIGN:
            case DELETE_CAMPAIGN:
            case RECEIVE_COURSE_CAMPAIGNS: {
        Severity: Minor
        Found in app/assets/javascripts/reducers/campaigns.js - About 1 hr to fix

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

          const showRecent = (course) => {
            // If the last update was not more than 7 days ago, show the 'recent edits'
            // count. Otherwise, it's out of date because the course is no longer being
            // updated.
            const lastUpdate = course.updates.last_update;
          app/assets/javascripts/components/students/components/Articles/SelectedStudent/ExercisesList/StudentExercisesList.jsx on lines 15..22

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

          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 showRecent = (course) => {
            // If the last update was not more than 7 days ago, show the 'recent edits'
            // count. Otherwise, it's out of date because the course is no longer being
            // updated.
            const lastUpdate = course.updates.last_update;
          app/assets/javascripts/components/students/shared/StudentList/StudentList.jsx on lines 17..24

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

          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

                      newAlerts.push(<CourseAlert key="submit" message={I18n.t('courses.review_timeline')} actionMessage={I18n.t('courses.launch_wizard')} buttonLink={`${courseLinkParams}/timeline/wizard`} />);
          Severity: Major
          Found in app/assets/javascripts/components/course/course_alerts.jsx and 1 other location - About 1 hr to fix
          app/assets/javascripts/components/course/course_alerts.jsx on lines 40..40

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

          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

            course: PropTypes.shape({
              account_requests_enabled: PropTypes.bool.isRequired,
              passcode: PropTypes.string.isRequired,
              published: PropTypes.bool.isRequired,
              student_count: PropTypes.number.isRequired,
          app/assets/javascripts/components/students/containers/Overview.jsx on lines 64..70

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

          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

                      newAlerts.push(<CourseAlert key="submit" message={I18n.t('courses.add_trainings')} actionMessage={I18n.t('courses.timeline_nav')} buttonLink={`${courseLinkParams}/timeline`} />);
          Severity: Major
          Found in app/assets/javascripts/components/course/course_alerts.jsx and 1 other location - About 1 hr to fix
          app/assets/javascripts/components/course/course_alerts.jsx on lines 43..43

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

          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

          Overview.propTypes = {
            course: PropTypes.object.isRequired,
            current_user: PropTypes.object.isRequired,
            prefix: PropTypes.string.isRequired,
            sortSelect: PropTypes.func.isRequired,
          app/assets/javascripts/components/students/components/Overview/Controls/Controls.jsx on lines 51..57

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

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

          const handleErrorNotification = function (data) {
            const notification = {};
          
            notification.closable = true;
            notification.type = 'error';
          Severity: Minor
          Found in app/assets/javascripts/reducers/notifications.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 refreshData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          export const refreshData = (location, args, dispatch) => {
            const {
              lastUserRequestTimestamp,
              courseSlug,
              articlesLimit,
          Severity: Minor
          Found in app/assets/javascripts/components/util/refresh.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 ArticleFinderSearchBar has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          function ArticleFinderSearchBar({ value, onChange, onSearch, disabled, wiki }) {
            const [suggestions, setSuggestions] = useState([]);
            const [isAutocompleteLoading, setAutocompleteLoading] = useState(false);
            let searchClass = 'article-finder-search-bar';
          
          

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

          const AddAvailableArticles = ({
            course_id,
            role,
            project,
            language,

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

          export const ModuleRow = ({ isStudent, module, trainingLibrarySlug }) => {
            const isTrainingModule = module.kind === TRAINING_MODULE_KIND;
            const isExercise = module.kind === EXERCISE_KIND;
            const isDiscussion = module.kind === DISCUSSION_KIND;
          
          

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

          const OverviewStats = ({ course }) => {
            const isWikidata = course.home_wiki.project === 'wikidata';
            const isWikipedia = course.home_wiki.project === 'wikipedia';
          
            const valueClass = (stat) => {
          Severity: Minor
          Found in app/assets/javascripts/components/overview/overview_stats.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 CourseTypeSelector has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          const CourseTypeSelector = (props) => {
            const _getFormattedCourseType = (type) => {
              return {
                ClassroomProgramCourse: 'Wikipedia Student Program',
                VisitingScholarship: 'Visiting Scholarship',
          Severity: Minor
          Found in app/assets/javascripts/components/overview/course_type_selector.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 NewReplyForm has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          const NewReplyForm = ({ ticket, currentUser }) => {
            const dispatch = useDispatch();
            const [replyDetails, setReplyDetails] = useState({
              cc: '',
              content: '',
          Severity: Minor
          Found in app/assets/javascripts/components/tickets/new_reply_form.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

          Severity
          Category
          Status
          Source
          Language