Before combining topics in a branch, ensure any descendant topicref with @chunk and no @href has a stub
770705
private void createChildTopicrefStubs(final List<Element> topicrefs) {
        if (!topicrefs.isEmpty()) {
            for (final Element currentElem : topicrefs) {
                final String href = getValue(currentElem, ATTRIBUTE_NAME_HREF);
                final String chunk = getValue(currentElem,ATTRIBUTE_NAME_CHUNK);
                if (href == null && chunk != null) {
                    generateStumpTopic(currentElem);
                }
                createChildTopicrefStubs(getChildElements(currentElem, MAP_TOPICREF));
            }
        }
    }
567267
private void mergeEntryWithoutSplit(Node node,
            Entry newEntry, long timestamp) {

        Entry nearestEntryToCarriedBuffer =
                node.nearestEntry(newEntry);
        double distanceNearestEntryToBuffer =
                nearestEntryToCarriedBuffer.calcDistance(newEntry);

        BestMergeInNode bestMergeInNode =
                calculateBestMergeInNode(node);

        if (distanceNearestEntryToBuffer < bestMergeInNode.distance) {
            nearestEntryToCarriedBuffer.aggregateEntry(newEntry, timestamp,
                    this.negLambda);
        } else {
            node.mergeEntries(bestMergeInNode.entryPos1,
                    bestMergeInNode.entryPos2);
            node.addEntry(newEntry, timestamp);
        }
    }
1081393
@Override
    public SpecTopic getClosestTopic(final SpecTopic topic, final SpecNode callerNode, final boolean checkParentNode) {
        final SpecTopic retValue = super.getClosestTopic(topic, callerNode, checkParentNode);
        if (retValue != null) {
            return retValue;
        } else {
            // Look up the metadata topics
            final ContentSpec contentSpec = getContentSpec();
            for (final Node contentSpecNode : contentSpec.getNodes()) {
                if (contentSpecNode instanceof KeyValueNode && ((KeyValueNode) contentSpecNode).getValue() instanceof SpecTopic) {
                    final SpecTopic childTopic = (SpecTopic) ((KeyValueNode) contentSpecNode).getValue();
                    if (childTopic == topic || childTopic.getId().equals(topic.getId())) {
                        return childTopic;
                    }
                }
            }

            return null;
        }
    }
110041
List<FilterUtils> combineFilterUtils(final Element topicref, final List<FilterUtils> filters,
                                         final SubjectScheme subjectSchemeMap) {
        return getChildElement(topicref, DITAVAREF_D_DITAVALREF)
                .map(ditavalRef -> getFilterUtils(ditavalRef).refine(subjectSchemeMap))
                .map(f -> {
                    final List<FilterUtils> fs = new ArrayList<>(filters.size() + 1);
                    fs.addAll(filters);
                    fs.add(f);
                    return fs;
                })
                .orElse(filters);
    }
100192
private void linkInPlace(Node<K, V> orphan, Node<K, V> n) {
        // link orphan at node's position
        orphan.y_s = n.y_s;
        if (n.y_s != null) {
            n.y_s.o_s = orphan;
        }
        orphan.o_s = n.o_s;
        if (n.o_s != null) {
            if (n.o_s.o_c == n) { // node is the oldest :(
                n.o_s.o_c = orphan;
            } else { // node has an older sibling!
                n.o_s.y_s = orphan;
            }
        }
        n.o_s = null;
        n.y_s = null;
    }
1012064
static function processNodeCombiningChildren( $useComments, $php, $tpl, &$nodeChildren, &$resourceData, &$parentNode )
    {
        $newNodeChildren = array();
        $lastNode = false;
        foreach ( $nodeChildren as $node )
        {
            $newNode = false;
            if ( !isset( $node[0] ) )
                continue;
            $nodeType = $node[0];
            if ( $nodeType == eZTemplate::NODE_ROOT )
            {
                $children = $node[1];
                $newNode = array( $nodeType,
                                  false );
                if ( $children )
                {
                    eZTemplateCompiler::processNodeCombiningChildren( $useComments, $php, $tpl, $children, $resourceData, $newNode );
                }
            }
            else if ( $nodeType == eZTemplate::NODE_TEXT )
            {
                $text = $node[2];
                $placement = $node[3];

                $newNode = array( $nodeType,
                                  false,
                                  $text,
                                  $placement );
                eZTemplateCompiler::combineStaticNodes( $tpl, $resourceData, $lastNode, $newNode );
            }
            else if ( $nodeType == eZTemplate::NODE_VARIABLE )
            {
                $variableCustom = $node[1];
                $variableData = $node[2];
                $variablePlacement = $node[3];
                $variableParameters = false;
                $dataInspection = eZTemplateCompiler::inspectVariableData( $tpl,
                                                                           $variableData, $variablePlacement,
                                                                           $resourceData );
                $newNode = $node;
                $newNode[1] = $variableCustom;
                unset( $dataInspection );
                eZTemplateCompiler::combineStaticNodes( $tpl, $resourceData, $lastNode, $newNode );
            }
            else if ( $nodeType == eZTemplate::NODE_FUNCTION )
            {
                $functionChildren = $node[1];
                $functionName = $node[2];
                $functionParameters = $node[3];
                $functionPlacement = $node[4];

                $newNode = array( $nodeType,
                                  false,
                                  $functionName,
                                  $functionParameters,
                                  $functionPlacement );
                if ( isset( $node[5] ) )
                    $newNode[5] = $node[5];

                if ( is_array( $functionChildren ) )
                {
                    eZTemplateCompiler::processNodeCombiningChildren( $useComments, $php, $tpl,
                                                                          $functionChildren, $resourceData, $newNode );
                }

            }
            else
                $newNode = $node;
            if ( $lastNode != false )
            {
                $newNodeChildren[] = $lastNode;
                $lastNode = false;
            }
            if ( $newNode != false )
                $lastNode = $newNode;
        }
        if ( $lastNode != false )
        {
            $newNodeChildren[] = $lastNode;
            $lastNode = false;
        }
        $parentNode[1] = $newNodeChildren;
    }
501544
public static void processTopicID(final BuildData buildData, final ITopicNode topicNode, final Document doc) {
        final BaseTopicWrapper<?> topic = topicNode.getTopic();

        // Ignore info topics
        if (!topic.hasTag(buildData.getServerEntities().getInfoTagId())) {
            // Get the id value
            final String errorXRefID = ((SpecNode) topicNode).getUniqueLinkId(buildData.isUseFixedUrls());

            // Set the id
            setDOMElementId(buildData.getDocBookVersion(), doc.getDocumentElement(), errorXRefID);
        }

        // Add the remap parameter
        final Integer topicId = topicNode.getDBId();
        doc.getDocumentElement().setAttribute("remap", "TID_" + topicId);
    }
373899
function addContentsDirectoryToReaddirResultAndCallOriginalCallback(err, entryNames) {
                                if (!err && Array.isArray(entryNames)) {
                                    entryNames = ['gitFakeFs'].concat(entryNames);
                                }
                                cb.call(this, err, entryNames);
                            }
1231618
private void filterTopics(final Element topicref, final List<FilterUtils> filters) {
        final List<FilterUtils> fs = combineFilterUtils(topicref, filters);

        final String href = topicref.getAttribute(ATTRIBUTE_NAME_HREF);
        final Attr skipFilter = topicref.getAttributeNode(SKIP_FILTER);
        final URI srcAbsUri = job.tempDirURI.resolve(map.resolve(href));
        if (!fs.isEmpty() && skipFilter == null
                && !filtered.contains(srcAbsUri)
                && !href.isEmpty()
                && !ATTR_SCOPE_VALUE_EXTERNAL.equals(topicref.getAttribute(ATTRIBUTE_NAME_SCOPE))
                && !ATTR_PROCESSING_ROLE_VALUE_RESOURCE_ONLY.equals(topicref.getAttribute(ATTRIBUTE_NAME_PROCESSING_ROLE))
                && isDitaFormat(topicref.getAttributeNode(ATTRIBUTE_NAME_FORMAT))) {
            final ProfilingFilter writer = new ProfilingFilter();
            writer.setLogger(logger);
            writer.setJob(job);
            writer.setFilterUtils(fs);
            writer.setCurrentFile(srcAbsUri);
            final List<XMLFilter> pipe = singletonList(writer);

            logger.info("Filtering " + srcAbsUri);
            try {
                xmlUtils.transform(srcAbsUri, pipe);
            } catch (final DITAOTException e) {
                logger.error("Failed to filter " + srcAbsUri + ": " + e.getMessage(), e);
            }
            filtered.add(srcAbsUri);
        }
        if (skipFilter != null) {
            topicref.removeAttributeNode(skipFilter);
        }

        for (final Element child: getChildElements(topicref, MAP_TOPICREF)) {
            if (DITAVAREF_D_DITAVALREF.matches(child)) {
                continue;
            }
            filterTopics(child, fs);
        }
    }
224099
def search_topics(self, query, **qualifiers):
        
        assert isinstance(query, (str, unicode)), query
        url_parameters = dict()

        query_chunks = []
        if query:  # pragma no branch (Should be covered)
            query_chunks.append(query)

        for qualifier, value in qualifiers.items():
            query_chunks.append("%s:%s" % (qualifier, value))

        url_parameters["q"] = ' '.join(query_chunks)
        assert url_parameters["q"], "need at least one qualifier"

        return github.PaginatedList.PaginatedList(
            github.Topic.Topic,
            self.__requester,
            "/search/topics",
            url_parameters,
            headers={
                "Accept": Consts.mediaTypeTopicsPreview
            }
        )
1358308
protected boolean checkTopicsForInvalidDuplicates(final ContentSpec contentSpec) {
        boolean valid = true;

        // Find all Topics that have two or more different revisions
        final List<ITopicNode> allTopicNodes = contentSpec.getAllTopicNodes();
        final Map<Integer, Map<Integer, Set<ITopicNode>>> invalidTopicNodes = new HashMap<Integer, Map<Integer, Set<ITopicNode>>>();

        for (final ITopicNode topicNode1 : allTopicNodes) {
            if (!topicNode1.isTopicAnExistingTopic()) continue;

            for (final ITopicNode topicNode2 : allTopicNodes) {
                // If the Topic isn't an existing topic and doesn't match the first spec topic's id, then continue
                if (topicNode1 == topicNode2 || !topicNode2.isTopicAnExistingTopic() || !topicNode1.getDBId().equals(topicNode2.getDBId()))
                    continue;

                // Check if the revisions between the two topics are the same
                if (topicNode1.getRevision() == null && topicNode2.getRevision() != null || topicNode1.getRevision() != null &&
                        topicNode2.getRevision() == null || topicNode1.getRevision() != null && !topicNode1.getRevision().equals(
                        topicNode2.getRevision())) {
                    if (!invalidTopicNodes.containsKey(topicNode1.getDBId())) {
                        invalidTopicNodes.put(topicNode1.getDBId(), new HashMap<Integer, Set<ITopicNode>>());
                    }

                    final Map<Integer, Set<ITopicNode>> revisionsToTopicNode = invalidTopicNodes.get(topicNode1.getDBId());
                    if (!revisionsToTopicNode.containsKey(topicNode1.getRevision())) {
                        revisionsToTopicNode.put(topicNode1.getRevision(), new HashSet<ITopicNode>());
                    }

                    revisionsToTopicNode.get(topicNode1.getRevision()).add(topicNode1);

                    valid = false;
                }
            }
        }

        // Loop through and generate an error message for each invalid topic
        for (final Entry<Integer, Map<Integer, Set<ITopicNode>>> entry : invalidTopicNodes.entrySet()) {
            final Integer topicId = entry.getKey();
            final Map<Integer, Set<ITopicNode>> revisionsToTopicNode = entry.getValue();

            final List<String> revNumbers = new ArrayList<String>();
            final List<Integer> revisions = new ArrayList<Integer>(revisionsToTopicNode.keySet());
            Collections.sort(revisions, new NullNumberSort<Integer>());

            for (final Integer revision : revisions) {
                final List<ITopicNode> topicNodes = new ArrayList<ITopicNode>(revisionsToTopicNode.get(revision));

                // Build up the line numbers message
                final StringBuilder lineNumbers = new StringBuilder();
                if (topicNodes.size() > 1) {
                    // Sort the Topics by line numbers
                    Collections.sort(topicNodes, new TopicNodeLineNumberComparator());

                    for (int i = 0; i < topicNodes.size(); i++) {
                        if (i == topicNodes.size() - 1) {
                            lineNumbers.append(" and ");
                        } else if (lineNumbers.length() != 0) {
                            lineNumbers.append(", ");
                        }

                        lineNumbers.append(topicNodes.get(i).getLineNumber());
                    }
                } else if (topicNodes.size() == 1) {
                    lineNumbers.append(topicNodes.get(0).getLineNumber());
                }

                // Build the revision message
                revNumbers.add(
                        String.format(ProcessorConstants.ERROR_TOPIC_WITH_DIFFERENT_REVS_REV_MSG, (revision == null ? "Latest" : revision),
                                lineNumbers));
            }

            final StringBuilder message = new StringBuilder(String.format(ProcessorConstants.ERROR_TOPIC_WITH_DIFFERENT_REVS_MSG, topicId));
            for (final String revNumber : revNumbers) {
                message.append(String.format(ProcessorConstants.CSLINE_MSG, revNumber));
            }

            log.error(message.toString());
        }

        return valid;
    }
342572
function extractOriginsOfChunkWithExtractedModules(chunk, reason = 'async commons') {
  return chunk.origins.map((origins, origin) => Object.assign({}, origin, {
    reasons: (origin.reasons || []).concat(reason)
  }))
}
538785
function fixrefs(scope, i) {
                        // do children first; order shouldn't matter
                        for (i = scope.children.length; --i >= 0;)
                                fixrefs(scope.children[i]);
                        for (i in scope.refs) if (HOP(scope.refs, i)) {
                                // find origin scope and propagate the reference to origin
                                for (var origin = scope.has(i), s = scope; s; s = s.parent) {
                                        s.refs[i] = origin;
                                        if (s === origin) break;
                                }
                        }
                }
771012
def build_branch_structure(self, model, skip):
        """"""
        self._history = dict()
        self._history["commits"] = commits = dict()
        self._history["branches"] = branches = dict()
        for branch in self._repo.refs:
            LOGGER.debug(branch.name)
            if branch.name in skip:
                continue
            branches[branch.name] = branch_history = list()
            latest = branch.commit
            history = [latest] + list(latest.iter_parents())
            for commit in history:
                # Find model in committed files.
                if not is_modified(model, commit):
                    LOGGER.info(
                        "The model was not modified in commit '{}'. "
                        "Skipping.".format(commit))
                    continue
                branch_history.append(commit.hexsha)
                if commit.hexsha not in commits:
                    commits[commit.hexsha] = sub = dict()
                    sub["timestamp"] = commit.authored_datetime.isoformat(" ")
                    sub["author"] = commit.author.name
                    sub["email"] = commit.author.email
        LOGGER.debug("%s", json.dumps(self._history, indent=2))
156745
function initLunr() {
    if (!endsWith(baseurl,"/")){
        baseurl = baseurl+'/'
    };

    // First retrieve the index file
    $.getJSON(baseurl +"index.json")
        .done(function(index) {
            pagesIndex =   index;
            // Set up lunrjs by declaring the fields we use
            // Also provide their boost level for the ranking
            lunrIndex = new lunr.Index
            lunrIndex.ref("uri");
            lunrIndex.field('title', {
                boost: 15
            });
            lunrIndex.field('tags', {
                boost: 10
            });
            lunrIndex.field("content", {
                boost: 5
            });

            // Feed lunr with each file and let lunr actually index them
            pagesIndex.forEach(function(page) {
                lunrIndex.add(page);
            });
            lunrIndex.pipeline.remove(lunrIndex.stemmer)
        })
        .fail(function(jqxhr, textStatus, error) {
            var err = textStatus + ", " + error;
            console.error("Error getting Hugo index flie:", err);
        });
}
946686
function applyTopicDescendents (f, property, topic, topics) {
    var node = ancestorTopicSearch(topic, topics);
    if (node.topic === topic) {
      return curryMap(property, f, descendents(node));
    }

    return null;
  }
1021529
def _prepare_output(topics_with_wrong_rf, verbose):
    """"""
    out = {}
    topics_count = len(topics_with_wrong_rf)
    out['raw'] = {
        'topics_with_wrong_replication_factor_count': topics_count,
    }

    if topics_count == 0:
        out['message'] = 'All topics have proper replication factor.'
    else:
        out['message'] = (
            "{0} topic(s) have replication factor lower than specified min ISR + 1."
        ).format(topics_count)

        if verbose:
            lines = (
                "replication_factor={replication_factor} is lower than min_isr={min_isr} + 1 for {topic}"
                .format(
                    min_isr=topic['min_isr'],
                    topic=topic['topic'],
                    replication_factor=topic['replication_factor'],
                )
                for topic in topics_with_wrong_rf
            )
            out['verbose'] = "Topics:\n" + "\n".join(lines)
    if verbose:
        out['raw']['topics'] = topics_with_wrong_rf

    return out