WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 462 of 1,666 total issues

Function CourseScoping has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const CourseScoping = ({ show, wizardController, showCourseDates }) => {
  const selectedScopingMethods = useSelector(state => state.scopingMethods.selected);
  const scopingMethods = [
    'index',
    ...selectedScopingMethods

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

const NewAccountModal = ({ course, passcode, currentUser, closeModal, newAccount, actions }) => {
  const checkAvailability = () => (actions.checkAvailability(newAccount));
  const createRequestedAccountImmediately = currentUser.isInstructor;
  const requestAccount = () => {
    actions.requestAccount(passcode, course, newAccount, createRequestedAccountImmediately);
Severity: Minor
Found in app/assets/javascripts/components/enroll/new_account_modal.jsx - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid deeply nested control flow statements.
Open

            if (moveUp) {
              const toWeekBlocks = this.getBlocksInWeek(toWeek.id);
              atIndex = toWeekBlocks.length;
            }
Severity: Major
Found in app/assets/javascripts/components/timeline/timeline.jsx - About 45 mins to fix

    Function InstructorStats has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const InstructorStats = ({ username, stats, maxProject, statsGraphsData, graphWidth, graphHeight, isStudent }) => {
      const [selectedGraph, setSelectedGraph] = useState('courses_count');
      const [coursesGraph, setCoursesGraph] = useState(true);
    
      const setCoursesCountGraph = () => {
    Severity: Minor
    Found in app/assets/javascripts/components/user_profiles/instructor_stats.jsx - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function SyllabusUpload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const SyllabusUpload = ({ course }) => {
      const [isUploadingSyllabus, setIsUploadingSyllabus] = useState(false);
      const dispatch = useDispatch();
    
      const onDrop = (files) => {
    Severity: Minor
    Found in app/assets/javascripts/components/overview/syllabus-upload.jsx - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function Reply has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export const Reply = ({ message }) => {
      const { sender, details } = message;
      let delivered_message;
      let failed_message;
      if (details.delivered) {
    Severity: Minor
    Found in app/assets/javascripts/components/tickets/reply.jsx - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function Sidebar has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const Sidebar = ({ createdAt, currentUser, ticket }) => {
      const dispatch = useDispatch();
      const navigate = useNavigate();
    
      const notifyOwner = () => {
    Severity: Minor
    Found in app/assets/javascripts/components/tickets/sidebar.jsx - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function TrainingModuleHandler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const TrainingModuleHandler = (props) => {
      useEffect(() => {
        const moduleId = document.getElementById('react_root').getAttribute('data-module-id');
        props.fetchTrainingModule({ module_id: moduleId });
      }, []);
    Severity: Minor
    Found in app/assets/javascripts/training/components/training_module_handler.jsx - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method calculate_week_meeting_dates has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def calculate_week_meeting_dates
        meetings = []
        @timeline_week_count.times do |wk|
          week_start = @beginning_of_first_week + wk.weeks
          # This excludes Sunday, putting the end of the week at Saturday.
    Severity: Minor
    Found in lib/course_meetings_manager.rb - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function Quiz has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const Quiz = (props) => {
      const [selectedAnswerId, setSelectedAnswerId] = useState(null);
    
     const setAnswer = (e) => {
        return setSelectedAnswerId(e.currentTarget.getAttribute('data-answer-id'));
    Severity: Minor
    Found in app/assets/javascripts/training/components/quiz.jsx - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method perform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def perform
        Course.current.each do |course|
          next unless course.flags[:salesforce_id]
          next unless course.approved?
          PushCourseToSalesforce.new(course)
    Severity: Minor
    Found in app/workers/daily_update/salesforce_sync_worker.rb - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method set_articles_edited has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_articles_edited
        @articles_edited = {}
        individual_courses.each do |course|
          individual_mainspace_edits(course).each do |edit|
            article_edits = @articles_edited[edit.article_id] || { new_article: false,
    Severity: Minor
    Found in app/presenters/individual_statistics_presenter.rb - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function YesNoSelector has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const YesNoSelector = (props) => {
        const initialState = props.course[props.courseProperty] ? I18n.t('application.opt_yes') : I18n.t('application.opt_no');
        const [selectedOption, setSelectedOption] = useState({ value: initialState, label: initialState });
    
      const _handleChange = (e) => {
    Severity: Minor
    Found in app/assets/javascripts/components/overview/yes_no_selector.jsx - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function getSlideInfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const getSlideInfo = (training, locale) => {
      let slideTitle;
      let assessment;
      let rawHtml;
      if (training.currentSlide.translations && training.currentSlide.translations[locale]) {
    Severity: Minor
    Found in app/assets/javascripts/training/components/training_slide_handler.jsx - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function SlideMenu has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const SlideMenu = (props) => {
      useEffect(() => {
        window.addEventListener('click', props.closeMenu, false);
    
        return () => {
    Severity: Minor
    Found in app/assets/javascripts/training/components/slide_menu.jsx - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def index # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
        @query = params[:search] if params[:search].present?
        @topic_slug = params[:topic] || DEFAULT_TOPIC unless @query || params[:all]
        @faqs = if @query
                  log_to_sentry
    Severity: Minor
    Found in app/controllers/faq_controller.rb - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function Footer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export const Footer = ({
      article, colors, failureMessage, showArticleFinder, highlightedHtml, isWhocolorLang,
      whoColorFailed, users, unhighlightedContributors, revisionId, toggleRevisionHandler, pendingRequest
    }) => {
      // Determine the Article Viewer Legend status based on what information

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

      def self.find_recent_plagiarism
        suspected_diffs = api_get('suspected_diffs')
        suspected_diffs.each do |rev|
          wiki = Wiki.find_by(language: rev['lang'], project: rev['project'])
          next unless wiki
    Severity: Minor
    Found in lib/importers/plagiabot_importer.rb - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Consider simplifying this complex logical expression.
    Open

    if platform.platform().lower().find('ubuntu') != -1 \
            or platform.platform().lower().find('wsl2') != -1 \
            or platform.platform().lower().find('debian') != -1 \
            or platform.platform().lower().find('elementary') != -1 \
            or platform.uname().version.lower().find('ubuntu') != -1:
    Severity: Major
    Found in setup.py - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

            if (this.state.value === nextState.value
                  && this.state.id === nextState.id
                  && this.state.invalid === nextState.invalid
                  && this.props.editable === nextProps.editable
                  && nextProps.rerenderHoc !== true
      Severity: Major
      Found in app/assets/javascripts/components/high_order/input_hoc.jsx - About 40 mins to fix
        Severity
        Category
        Status
        Source
        Language