indigotech / danger

Danger scripts for Taqtile projects
MIT License
1 stars 1 forks source link

Check for hardcoded color and fonts on nib files #34

Closed eiditakahashi closed 7 years ago

eiditakahashi commented 7 years ago
eiditakahashi commented 7 years ago

Tested on a PR and result was: <color key="backgroundColor" red="1" green="0.99997437000274658" blue="0.99999129772186279" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="0.99997437000274658" blue="0.99999129772186279" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>

@ghashi can you confirm if regex is getting the correct result?

ghashi commented 7 years ago

@eiditakahashi Just the last color seems to be "black", therefore shouldn't be there. The others seems to be "hardcoded".

ps: this is the script on "Partograma"

function find_hardcoded_colors {
  color_count=$(find $project_path -name *.xib -not -path "$project_path/.git/*" -not -path "$project_path/Pods/*" -print0 | xargs -0 grep -i 'color' \
    | grep -v 'white="1"' \
    | grep -v 'white="0.0"' \
    | grep -v 'red="0.93725490196078431" green="0.93725490196078431" blue="0.95686274509803926" alpha="1"' \
    | grep -v 'red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1"' \
    | grep -v 'red="0.0" green="0.0" blue="0.0"' \
    | grep -v 'red="1" green="1" blue="1" alpha="1"' \
    | grep -v '<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>' \
    | grep -v '<color key="titleShadowColor"' \
    | grep -v 'cocoaTouchSystemColor' \
    | grep -v '<nil' \
    | grep -v '<view' \
    | grep -v 'userDefinedRuntimeAttribute' \
    | grep -v '<string key="text"' \
    | grep -v 'image' \
    | grep -v '</string>' \
    | grep -v '<label' \
    | grep -v '<document' \
    | wc -l)
  assert_message "Number of hardcoded COLORS:" $expected_hardcoded_colors $color_count
}

ps2: this part of the script grep -v 'red="0.0" green="0.0" blue="0.0"' should remove the last color <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/> , shouldn't?

eiditakahashi commented 7 years ago

@ghashi When I created the regex I was using an old version of this script and this line was different. Updating the line removed the last color! Thanks!