WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 462 of 1,666 total issues

Function Actions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export const Actions = ({
  article, assignment, courseSlug, current_user, isComplete, username,
  isEnglishWikipedia, isClassroomProgram, unassign, course
}) => {
  if (isComplete) {

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 10 (exceeds 5 allowed). Consider refactoring.
Open

  def create_alerts
    @courses.each do |course|
      next if Alert.exists?(course_id: course.id,
                            type: 'ContinuedCourseActivityAlert',
                            resolved: false)
Severity: Minor
Found in lib/alerts/continued_course_activity_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 Category has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const Category = ({ course, category, remove, editable }) => {
  let removeButton;
  if (editable) {
    removeButton = (
      <button className="button pull-right small danger" onClick={remove}>
Severity: Minor
Found in app/assets/javascripts/components/categories/category.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 sender has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def sender
      message = messages.first
      return {} unless message
      
      user = message.sender if message
Severity: Minor
Found in config/initializers/ticket_dispenser.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

Method create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def create
      @question_group = Rapidfire::QuestionGroup.new(question_group_params)
      if @question_group.save
        respond_to do |format|
          if params.key?(:redirect_to_edit)
Severity: Minor
Found in config/initializers/surveys.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

Method try_to_process_notifications has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def try_to_process_notifications(method)
    SurveyNotification.active.email_enabled.each do |notification|
      @notification = notification
      # Sending an email and updating the record returns true.
      # When no email needs to be sent, the email methods return nil.
Severity: Minor
Found in lib/data_cycle/survey_update.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 fetchKeywordResults has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const fetchKeywordResults = (keyword, wiki, offset = 0, continueResults = false) => (dispatch, getState) => {
  if (!continueResults) {
    dispatch({
      type: INITIATE_SEARCH
    });
Severity: Minor
Found in app/assets/javascripts/actions/article_finder_action.js - About 1 hr to fix

    Function getCourseApprovalStaff has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      [getSpecialUsers, getStaffUsers], (specialUsers, staffUsers) => {
        // Compare staff users of a course with classroom program manager and
        // wiki expert users. Make a list of all Special Users objects with
        // required information. Mark any user in the list as already_selected
        // if they have already been selected as a staff user, to prevent them
    Severity: Minor
    Found in app/assets/javascripts/selectors/index.js - About 1 hr to fix

      Function DefaultCampaignForm has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const DefaultCampaignForm = (props) => {
        const [default_campaign_slug, setDefault_campaign_slug] = useState(null);
      
        const handleChange = (key, value) => {
          setDefault_campaign_slug(value);

        Function trainingSelector has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          trainingSelector() {
            const MultiValueRemove = (props) => {
              return (
                <components.MultiValueRemove {...props}>
                  <components.CrossIcon aria-hidden={false} aria-label={'Remove Module'} />

          Function AssignCell has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const AssignCell = (props) => {
            const {
              assignments, course, current_user,
              editable, isStudentsPage, prefix, student
            } = props;
          Severity: Minor
          Found in app/assets/javascripts/components/common/AssignCell/AssignCell.jsx - About 1 hr to fix

            Function render has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            render() {
              const { is_open } = this.props;
              const editRow = (
                <tr className="edit">
                  <td>

              Function answersList has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const answersList = () => {
                  const answers = answers_data;
                  const list = answers.map((answer) => {
                    const { course, data: answerData, user, sentiment: answerSentiment } = answer;
                    const courseTitle = course === null ? null : course.title;
              Severity: Minor
              Found in app/assets/javascripts/surveys/components/TextResults.jsx - About 1 hr to fix

                Method base_salesforce_fields has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def base_salesforce_fields
                    {
                      Name: @course.title,
                      Course_Page__c: @course.url,
                      Course_End_Date__c: @course.end.strftime('%Y-%m-%d'),
                Severity: Minor
                Found in app/services/push_course_to_salesforce.rb - About 1 hr to fix

                  Function RecentEditsHandler has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const RecentEditsHandler = () => {
                    const myCoursesRef = useRef(null);
                  
                    const dispatch = useDispatch();
                    const revisions = useSelector(state => state.recentEdits.revisions);
                  Severity: Minor
                  Found in app/assets/javascripts/components/activity/recent_edits_handler.jsx - About 1 hr to fix

                    Function SelectedWikiOption has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const SelectedWikiOption = (props) => {
                      const [show, setShow] = useState(false);
                      const handleShowOptions = (e) => {
                        e.preventDefault();
                        setShow(true);
                    Severity: Minor
                    Found in app/assets/javascripts/components/common/selected_wiki_option.jsx - About 1 hr to fix

                      Function handleCourse has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        handleCourse(course, isValidProp) {
                          if (this.state.shouldRedirect === true) {
                            window.location = `/courses/${course.slug}`;
                            return this.setState({ shouldRedirect: false });
                          }
                      Severity: Minor
                      Found in app/assets/javascripts/components/course_creator/course_creator.jsx - About 1 hr to fix

                        Function SiteNoticeSetting has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const SiteNoticeSetting = () => {
                          const dispatch = useDispatch();
                          useEffect(() => {
                            dispatch(getSiteNotice());
                          }, []);
                        Severity: Minor
                        Found in app/assets/javascripts/components/settings/site_notice_setting.jsx - About 1 hr to fix

                          Function render has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            render() {
                              if (this.props.editable) {
                                return this.trainingSelector();
                              }
                          
                          

                            Function fetchDiff has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              fetchDiff(diffUrl) {
                                fetch(diffUrl)
                                .then(resp => resp.json())
                                .then((data) => {
                                  let firstRevisionData;
                            Severity: Minor
                            Found in app/assets/javascripts/components/revisions/diff_viewer.jsx - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language