<commit_before>import { BaseModel } from '../shared/models/base.model';
import { FieldMapper } from '../shared/decorators/field-mapper.decorator';

@FieldMapper({
  ruleid: 'ruleId',
  cidr: 'CIDR',
  startport: 'startPort',
  endport: 'endPort',
  icmpcode: 'icmpCode',
  icmptype: 'icmpType',
})
export class NetworkRule extends BaseModel {
  public ruleId: string;
  public protocol: string;
  public CIDR: string;
  public startPort?: number;
  public endPort?: number;
  public icmpCode?: number;
  public icmpType?: number;
}

interface ITag {
  key: string;
  value: string;
}

@FieldMapper({
  ingressrule: 'ingressRules',
  egressrule: 'egressRules'
})
export class SecurityGroup extends BaseModel {
  public id: string;
  public name: string;
  public description: string;
  public account: string;
  public domain: string;
  public ingressRules: Array<NetworkRule>;
  public egressRules: Array<NetworkRule>;
  public tags: Array<ITag>;

  public get labels() {
    return this._labels;
  }

  public set labels(value) {
    this._labels = value;
  }

  private _labels: Array<string>;

  constructor(params?: {}) {
    super(params);

    for (let i = 0; i < this.ingressRules.length; i++) {
      this.ingressRules[i] = new NetworkRule(this.ingressRules[i]);
    }

    for (let i = 0; i < this.egressRules.length; i++) {
      this.egressRules[i] = new NetworkRule(this.egressRules[i]);
    }

    if (!this.tags) {
      return;
    }

    for (let i = 0; i < this.tags.length; i++) {
      const key = this.tags[i].key;
      if (key !== 'labels') {
        continue;
      }

      this.labels = this.tags[i].value.split(';');
      this.tags.splice(i, 1);
      break;
    }
  }

  public serialize() {
    const model: any = super.serialize();

    model.tags.push(this.labels.join(';'));
    return model;
  }
}<commit_msg>code review fixes<commit_after>import { BaseModel } from '../shared/models/base.model';
import { FieldMapper } from '../shared/decorators/field-mapper.decorator';

@FieldMapper({
  ruleid: 'ruleId',
  cidr: 'CIDR',
  startport: 'startPort',
  endport: 'endPort',
  icmpcode: 'icmpCode',
  icmptype: 'icmpType',
})
export class NetworkRule extends BaseModel {
  public ruleId: string;
  public protocol: string;
  public CIDR: string;
  public startPort?: number;
  public endPort?: number;
  public icmpCode?: number;
  public icmpType?: number;
}

interface ITag {
  key: string;
  value: string;
}

@FieldMapper({
  ingressrule: 'ingressRules',
  egressrule: 'egressRules'
})
export class SecurityGroup extends BaseModel {
  public id: string;
  public name: string;
  public description: string;
  public account: string;
  public domain: string;
  public ingressRules: Array<NetworkRule>;
  public egressRules: Array<NetworkRule>;
  public tags: Array<ITag>;

  private _labels: Array<string>;

  constructor(params?: {}) {
    super(params);

    for (let i = 0; i < this.ingressRules.length; i++) {
      this.ingressRules[i] = new NetworkRule(this.ingressRules[i]);
    }

    for (let i = 0; i < this.egressRules.length; i++) {
      this.egressRules[i] = new NetworkRule(this.egressRules[i]);
    }

    if (!this.tags) {
      return;
    }

    for (let i = 0; i < this.tags.length; i++) {
      const key = this.tags[i].key;
      if (key !== 'labels') {
        continue;
      }

      this.labels = this.tags[i].value.split(';');
      this.tags.splice(i, 1);
      break;
    }
  }

  public get labels() {
    return this._labels;
  }

  public set labels(value) {
    this._labels = value;
  }

  public serialize() {
    const model: any = super.serialize();

    model.tags.push(this.labels.join(';'));
    return model;
  }
}
{'fraction_non_alphanumeric': 0.1447939262472885, 'fraction_numerical': 0.0021691973969631237, 'mean_word_length': 3.225658648339061, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 11, 'https://': 0, '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': '5620585', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1237, 'n_words': 308}