<commit_before>import url from 'url';

import React from 'react';
import ReactDom from 'react-dom';
import Relay from 'react-relay';
import yubikiri from 'yubikiri';
import {autobind} from 'core-decorators';

import RelayNetworkLayerManager from '../relay-network-layer-manager';
import RelayRootContainer from '../containers/relay-root-container';
import GithubLoginModel, {UNAUTHENTICATED} from '../models/github-login-model';
import ObserveModel from '../views/observe-model';
import PrInfoByNumberRoute from '../routes/pr-info-by-number-route';

function getPropsFromUri(uri) {
  // atom-github://pull-request/https://github-host.tld/owner/repo/prNumber
  const {protocol, hostname, pathname} = url.parse(uri);
  if (protocol === 'atom-github:' && hostname === 'pull-request') {
    const [scheme, host, owner, repo, prNum] = pathname.split('/').filter(s => s);
    if (!scheme || !host || !owner || !repo || !prNum) { return null; }
    const prNumber = parseInt(prNum, 10);
    if (isNaN(prNumber)) { return null; }
    return {owner, repo, prNumber, host: `${scheme}//${host}`};
  }
  return null;
}

export default class PrPaneItemController extends React.Component {
  static create({owner, repo, prNumber, host}, uri) {
    let element;
    return {
      serialize() {
        return {
          uri,
          deserializer: 'PrPaneItemController',
        };
      },
      getURI() { return uri; },
      getTitle() { return `PR: ${owner}/${repo}#${prNumber}`; },
      get element() {
        if (!element) {
          element = document.createElement('div');
          const loginModel = GithubLoginModel.get();
          const props = {owner, repo, prNumber, host, loginModel};
          ReactDom.render(<PrPaneItemController {...props} />, element);
        }
        return element;
      },
    };
  }

  static opener(uri) {
    const props = getPropsFromUri(uri);
    if (props) {
      return this.create(props, uri);
    } else {
      return null;
    }
  }

  static propTypes = {
    owner: React.PropTypes.string.isRequired,
    repo: React.PropTypes.string.isRequired,
    prNumber: React.PropTypes.number.isRequired,
    host: React.PropTypes.string,
    loginModel: React.PropTypes.instanceOf(GithubLoginModel).isRequired,
  }
<commit_msg>Don't use `this` in static method<commit_after>import url from 'url';

import React from 'react';
import ReactDom from 'react-dom';
import Relay from 'react-relay';
import yubikiri from 'yubikiri';
import {autobind} from 'core-decorators';

import RelayNetworkLayerManager from '../relay-network-layer-manager';
import RelayRootContainer from '../containers/relay-root-container';
import GithubLoginModel, {UNAUTHENTICATED} from '../models/github-login-model';
import ObserveModel from '../views/observe-model';
import PrInfoByNumberRoute from '../routes/pr-info-by-number-route';

function getPropsFromUri(uri) {
  // atom-github://pull-request/https://github-host.tld/owner/repo/prNumber
  const {protocol, hostname, pathname} = url.parse(uri);
  if (protocol === 'atom-github:' && hostname === 'pull-request') {
    const [scheme, host, owner, repo, prNum] = pathname.split('/').filter(s => s);
    if (!scheme || !host || !owner || !repo || !prNum) { return null; }
    const prNumber = parseInt(prNum, 10);
    if (isNaN(prNumber)) { return null; }
    return {owner, repo, prNumber, host: `${scheme}//${host}`};
  }
  return null;
}

export default class PrPaneItemController extends React.Component {
  static create({owner, repo, prNumber, host}, uri) {
    let element;
    return {
      serialize() {
        return {
          uri,
          deserializer: 'PrPaneItemController',
        };
      },
      getURI() { return uri; },
      getTitle() { return `PR: ${owner}/${repo}#${prNumber}`; },
      get element() {
        if (!element) {
          element = document.createElement('div');
          const loginModel = GithubLoginModel.get();
          const props = {owner, repo, prNumber, host, loginModel};
          ReactDom.render(<PrPaneItemController {...props} />, element);
        }
        return element;
      },
    };
  }

  static opener(uri) {
    const props = getPropsFromUri(uri);
    if (props) {
      return PrPaneItemController.create(props, uri);
    } else {
      return null;
    }
  }

  static propTypes = {
    owner: React.PropTypes.string.isRequired,
    repo: React.PropTypes.string.isRequired,
    prNumber: React.PropTypes.number.isRequired,
    host: React.PropTypes.string,
    loginModel: React.PropTypes.instanceOf(GithubLoginModel).isRequired,
  }

{'fraction_non_alphanumeric': 0.1484477481416703, 'fraction_numerical': 0.0008745080891998251, 'mean_word_length': 3.2282809611829943, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, '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': '1777135', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1399, 'n_words': 331}