Changeset 216000 in webkit


Ignore:
Timestamp:
Apr 30, 2017 4:39:51 PM (7 years ago)
Author:
mitz@apple.com
Message:

[Cocoa] Have check-webkit-style advise against use of [get…Class() alloc]
https://bugs.webkit.org/show_bug.cgi?id=171486

Reviewed by Sam Weinig.

  • Scripts/webkitpy/style/checkers/cpp.py:

(check_soft_link_class_alloc): Added. Looks for [get…Class() alloc] and suggests

alloc…Instance() instead.

(check_style): Invoke new check.

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r215997 r216000  
     12017-04-30  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] Have check-webkit-style advise against use of [get…Class() alloc]
     4        https://bugs.webkit.org/show_bug.cgi?id=171486
     5
     6        Reviewed by Sam Weinig.
     7
     8        * Scripts/webkitpy/style/checkers/cpp.py:
     9        (check_soft_link_class_alloc): Added. Looks for [get…Class() alloc] and suggests
     10          alloc…Instance() instead.
     11        (check_style): Invoke new check.
     12
    1132017-04-30  Brady Eidson  <beidson@apple.com>
    214
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py

    r207559 r216000  
    27302730
    27312731
     2732def check_soft_link_class_alloc(clean_lines, line_number, error):
     2733    """Checks that allocating an instance of a soft-linked class uses alloc[Class]Instance.
     2734
     2735    Args:
     2736      clean_lines: A CleansedLines instance containing the file.
     2737      line_number: The number of the line to check.
     2738      error: The function to call with any errors found.
     2739    """
     2740
     2741    line = clean_lines.elided[line_number]
     2742
     2743    matched = search(r'\[get([^\s]+)Class\(\)\s+alloc\]', line)
     2744    if matched:
     2745        error(line_number, 'runtime/soft-linked-alloc', 4,
     2746              'Using +alloc with a soft-linked class. Use alloc%sInstance() instead.' % matched.group(1))
     2747
     2748
    27322749def get_line_width(line):
    27332750    """Determines the width of the line in column positions.
     
    28232840    check_for_comparisons_to_zero(clean_lines, line_number, error)
    28242841    check_for_null(clean_lines, line_number, file_state, error)
     2842    check_soft_link_class_alloc(clean_lines, line_number, error)
    28252843    check_indentation_amount(clean_lines, line_number, error)
    28262844    check_enum_casing(clean_lines, line_number, enum_state, error)
Note: See TracChangeset for help on using the changeset viewer.