<commit_before>#!/usr/bin/env python2
#* This file is part of the MOOSE framework
#* https://www.mooseframework.org
#*
#* All rights reserved, see COPYRIGHT for full restrictions
#* https://github.com/idaholab/moose/blob/master/COPYRIGHT
#*
#* Licensed under LGPL 2.1, please see LICENSE for details
#* https://www.gnu.org/licenses/lgpl-2.1.html

import os
import collections
import subprocess
from hit_load import hit_load
from mooseutils import git_root_dir, colorText

def check_requirement(filename):
    """Check spec file for requirement documentation."""

    messages = []
    root = hit_load(filename)
    design = root.children[0].get('design', '')
    issues = root.children[0].get('issues', '')
    deprecated = root.children[0].get('deprecated', False)

    for child in root.children[0]:
        if child.get('deprecated', deprecated):
            continue

        if 'requirement' not in child:
            messages.append("    'requirement' parameter is missing or empty in '{}' block.".format(child.name))

        if not child.get('design', design).strip():
            messages.append("    'design' parameter is missing or empty in '{}' block.".format(child.name))

        if not child.get('issues', issues).strip():
            messages.append("    'issues' parameter is missing or empty in '{}' block.".format(child.name))

    if messages:
        print 'ERROR in {}'.format(filename)
        print '\n'.join(messages) + '\n'
        return 1
    return 0

def sqa_check(working_dir=os.getcwd(), remote='origin', branch='devel', specs=['tests'], skip=[]):
    """Check that test specifications that were modified include requirements."""

    # Fetch
    cmd = ['git', 'fetch', remote]<commit_msg>Improve SQA check script to consider groups/details<commit_after>#!/usr/bin/env python2
#* This file is part of the MOOSE framework
#* https://www.mooseframework.org
#*
#* All rights reserved, see COPYRIGHT for full restrictions
#* https://github.com/idaholab/moose/blob/master/COPYRIGHT
#*
#* Licensed under LGPL 2.1, please see LICENSE for details
#* https://www.gnu.org/licenses/lgpl-2.1.html

import os
import collections
import subprocess
from hit_load import hit_load
from mooseutils import git_root_dir, colorText

def check_requirement(filename):
    """Check spec file for requirement documentation."""

    messages = []
    root = hit_load(filename)
    design = root.children[0].get('design', '')
    issues = root.children[0].get('issues', '')
    deprecated = root.children[0].get('deprecated', False)

    for child in root.children[0]:
        if child.get('deprecated', deprecated):
            continue

        if 'requirement' not in child:
            messages.append("    'requirement' parameter is missing or empty in '{}' block.".format(child.name))

        if not child.get('design', design).strip():
            messages.append("    'design' parameter is missing or empty in '{}' block.".format(child.name))

        if not child.get('issues', issues).strip():
            messages.append("    'issues' parameter is missing or empty in '{}' block.".format(child.name))

        for grandchild in child.children:
            if 'detail' not in grandchild:
                messages.append("    'detail' parameter is missing or empty in '{}' block.".format(grandchild.name))

            if 'requirement' in grandchild:
                messages.append("    'requirement' parameter in block '{}' must not be used within a group, use 'detail' instead.".format(grandchild.name))

            if 'design' in grandchild:
                messages.append("    'design' parameter in block '{}' must not be used within a group.".format(grandchild.name))

            if 'issues' in grandchild:
                messages.append("    'issues' parameter in block '{}' must not be used within a group.".format(grandchild.name))

    if messages:
        print 'ERROR in {}'.format(filename)
        print '\n'.join(messages) + '\n'
        return 1
    return 0

def sqa_check(working_dir=os.getcwd(), remote='origin', branch='devel', specs=['tests'], skip=[]):
    """Check that test specifications that were modified include requirements."""

    # Fetch
    cmd = ['git', 'fetch', remote]
{'fraction_non_alphanumeric': 0.1350071056371388, 'fraction_numerical': 0.005210800568450971, 'mean_word_length': 3.1483300589390963, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3688547', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1179, 'n_words': 362}