Plugin for Task Management in xcode - objective-c

Is there any plugin for task management ( bug tracking, issues) to use with xcode? Or there's any plugin api that one can create plugins for it?

There really isnt anything that I know of that is as good as mylyn to intergrate with bugzilla or trac. If you found anything, please let me know!
The best way I know of to document issues or things is to put a //TODO: or //FIXME: in your code. Then when Xcode compiles you can run a local shell script to post warnings for you
Its here: (Targets --> --> BUILD PHASES --> Run Scripts (See Screenshot)
Put this script at the end of your Build Phases :
KEYWORDS="FIXME|TODO:|FIXME:|\?\?\?:|\!\!\!:"
find ${SRCROOT} \( -name "*.h" -or -name "*.m" \) -print0 | \
xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | \
perl -p -e "s/($KEYWORDS)/ warning: \$1/"
Lastly there is the infamous
#pragma mark YOURTEXTHERE
Good Luck!
Here is a wishlist of things people want: https://stackoverflow.com/questions/2025605/wishlist-for-objective-c-ide-xcode
Screenshot:

I've been using the Run Script build phase for a while now and modified it so the generated build warnings directly link to the file and line where the keyword has been found.
The solution is just to print a line which matches the ones Xcode knows how to parse:
{filename}:{line}:{character}: warning: {The content of the warning}.
So the script looks like that:
KEYWORDS="FIXME|TODO:|FIXME:|\?\?\?:|\!\!\!:\#todo\#warning"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -exec egrep -Hno "($KEYWORDS).*\$" {} \; | \
sed -e 's/^\([^:]\{1,\}\):\([0-9]\{1,\}\):\(.*\)$/\1:\2:1: warning: \3/'
Note that I also included #todo and #warning in the keywords as I often use javadoc/doxygen comments.
Bertrand

I made a Xcode plugin for this --> http://github.com/trawor/XToDo

Related

Run sql-lint on more than one file

Is there a way to run sql-lint on a bunch of files? All examples show how to run sql-lint on one file only (sql-lint -f ).
Thanks!
Author of sql-lint here. There's some upcoming work to make it recurse down and lint every SQL file. In the meantime you can use this:
find . -iname "*.sql" | xargs -L1 sql-lint -f
Hope that helps!

PMD working inside intellij as an External Tool

I would like to make it so that I can Run a PMD check as an external tool from withing intellij 14.x
The only documentation I can find is old and outdated based on pmd 4.x. How do I get it working correctly? Is anyone out there using PMD as an external Tool? I tried downloading the built in PMD plugin but when I pointed it to my custom_pmd_ruleset.xml it ignored it entirely --> perhaps the plugin is broken.
The command line parser has changed in PMD 5.0.1, but the documentation was never updated unfortunately. These are the changes:
args[0] is now -dir
args[1] is now -format
args[2] is now -rulesets
When you -format ideaj, it also needs three more arguments. Those report format specific arguments are now specified with -property {name}={value}:
args[3] is now -property sourcePath
args[4] is now -property classAndMethodName
args[5] is now -property singleFileName
The example command line given in the PMD 4 documentation used parameters:
"$FilePath$" # args[0]
ideaj # args[1]
unusedcode,imports # args[2]
"$Sourcepath$" # args[3]
$FileClass$.method # args[4]
$FileName$ # args[5]
Notice that the 4th argument was actually wrong in the documentation, $FileClass.method should be $FileClass$.method.
So in PMD 5, this is:
pmd \
-dir "$FilePath$" \
-format ideaj \
-rulesets "unusedcode,imports" \
-property sourcePath="$Sourcepath$" \
-property classAndMethodName="$FileClass$.method" \
-property singleFileName="$FileName$
You can configure IntelliJ like this:
File > Settings
Tools > External Tools
Add a new external tool:
Name: PMD (or anything you like)
Description: PMD source code analyzer (or anything you like)
Options: Synchronize files after execution; Open console
Show in: Main menu; Editor menu; Project views; Search results
Program: path/to/pmd-bin-5.8.1/bin/run.sh
Parameters: pmd -dir "$FilePath$" -format ideaj -rulesets "unusedcode,imports" -property sourcePath="$Sourcepath$" -property classAndMethodName="$FileClass$.method" -property singleFileName="$FileName$
Working Directory: $ProjectFileDir$
After a fair bit of research, here's what worked for me:
And here's the classpath part that's super long and cut off in the image:
-cp "C:\Users\nate\.m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar;C:\Users\nate\.m2\repository\org\apache\commons\commons-lang3\3.3.2\commons-lang3-3.3.2.jar;C:\Users\nate\.m2\repository\net\sourceforge\pmd\pmd-core\5.3.2\pmd-core-5.3.2.jar;C:\Users\nate\.m2\repository\net\sourceforge\pmd\pmd-java\5.3.2\pmd-java-5.3.2.jar;C:\Users\nate\.m2\repository\asm\asm\3.1\asm-3.1.jar;C:\Users\nate\.m2\repository\jaxen\jaxen\1.1.1\jaxen-1.1.1.jar;C:\Users\nate\.m2\repository\com\beust\jcommander\1.48\jcommander-1.48.jar" net.sourceforge.pmd.PMD -R "$ModuleFileDir$\src\test\resources\custom-pmd-rules.xml" -d "$FileDirRelativeToProjectRoot$/$FileName$"
Hopefully that saves someone some time getting it working. Enjoy.

Issue with genstrings for Swift file

genstrings works well to extract localizable content from .m file as,
find . -name \*.m | xargs genstrings -o en.lproj
But, not working for .swift file as,
find . -name \*.swift | xargs genstrings -o en.lproj
The genstrings tool works fine with swift as far as I am concerned. Here is my test:
// MyClass.swift
let message = NSLocalizedString("This is the test message.", comment: "Test")
then, in the folder with the class
# generate strings for all swift files (even in nested directories)
$ find . -name \*.swift | xargs genstrings -o .
# See results
$ cat Localizable.strings
/* Test */
"This is the test message." = "This is the test message.";
$
I believe genstrings works as intended, however Apple's xargs approach to generate strings from all your project's files is flawed and does not properly parse paths containing spaces.
That might be the reason why it's not working for you.
Try using the following:
find . -name \*.swift | tr '\n' '\0' | xargs -0 genstrings -o .
We wrote a command line tool that works for Swift files and merges the result of apples genstrings tool.
It allows for key and value in NSLocalizedString
https://github.com/KeepSafe/genstrings_swift
There's an alternative tool called SwiftGenStrings
Hello.swift
NSLocalizedString("hello", value: "world", comment: "Hi!")
SwiftGenStrings:
$ SwiftGenStrings Hello.swift
/* Hi! */
"hello" = "world";
Apple genstrings:
$ genstrings Hello.swift
Bad entry in file Hello.swift (line = 1): Argument is not a literal string.
Disclaimer: I worked on SwiftGenStrings.
There is a similar question here:
How to use genstrings across multiple directories?
find ./ -name "*.m" -print0 | xargs -0 genstrings -o en.lproj
The issue I was having with find/genstrings was twofold:
When it reached folder names with spaces (generated by the output of find), it would exit with an error
When it reached the file where I had my custom routine defined, it was giving me an error when trying to parse my actual function definition
To fix both those problems I'm using the following:
find Some/Path/ \( -name "*.swift" ! -name "MyExcludedFile.swift" \) | sed "s/^/'/;s/$/'/" | xargs genstrings -o . -s MyCustomLocalizedStringRoutine
To summarize, we use the find command to both find and exclude your Swift files, then pipe the results into the sed command which will wrap each file path in quotes, then finally pipe that result into the genstrings command
Xcode now includes a powerful tool for extracting localizations.
Just select your project on the left then Editor menu >> Export localizations.
You'll get a folder with all the text in your files as well as the Localizable.strings and InfoPlist.strings
More details here:
https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPInternational/LocalizingYourApp/LocalizingYourApp.html

Makefile and use of $$

So I have a Makefile in which I have the follwoing code that I try to understand:
for file_exe in `find . -name "zip_exe-*"`; do \
./$${file_exe} -d $(UNZIP_PATH)/lib; \
done
As I understand this piece of code will try to find some executable zip and the extract those zip files to a locations. But what puzzles me is how $${file_exe} is working. Why is the double $$ needed? I guess it has something to do with the fact that some bash commands are running from a makefile, but I can't explain to myself why the $$ is needed and a simple $ does not work since this command is running a sub-shell anyway.
Make needs to distinguish whether you want a $ to use as introducing a make-variable reference, such as ${FOOBAR} or as a plain $ passed on to the shell. The make specification (Section Macros) says that to do the latter, you must use $$ which is replaced by a single $ and passed to the shell. In effect, your snippet reads as
for file_exe in `find . -name "zip_exe-*"`; do \
./${file_exe} -d some/unzip/path/lib; \
done
to the shell.
Style note: Iterating over file lists created by backticks is considered bad style, since it may overflow the ARG_MAX limit. Better to read the file names one-by-one with
find . -name "zip_exe-*" | \
while read -r file_exe; do \
./${file_exe} -d some/unzip/path/lib; \
done

How to detect code change frequency?

I am working on a program written by several folks with largely varying skill level. There are files in there that have never changed (and probably never will, as we're afraid to touch them) and others that are changing constantly.
I wonder, are there any tools out there that would look at the entire repo history (git) and produce analysis on how frequently a given file changes? Or package? Or project?
It would be of value to recognize that (for example) we spent 25% of our time working on a set of packages, which would be indicative or code's fragility, as compared with code that "just works".
If you're looking for an OS solution, I'd probably consider starting with gitstats and look at extending it by grabbing file logs and aggregating that data.
I'd have a look at NChurn:
NChurn is a utility that helps asses the churn level of your files in
your repository. Churn can help you detect which files are changed the
most in their life time. This helps identify potential bug hives, and
improper design.The best thing to do is to plug NChurn into your build
process and store history of each run. Then, you can plot the
evolution of your repository's churn.
I wrote something that we use to visualize this information successfully.
https://github.com/bcarlso/defect-density-heatmap
Take a look at the project and you can see what the output looks like in the readme.
You can do what you need by first getting a list of files that have changed in each commit from Git.
~ $ git log --pretty="format:" --name-only | grep -v ^$ > file-changes.txt
~ $ for i in `cat file-changes.txt | cut -d"." -f1,2 | uniq`; do num=`cat file-changes.txt | grep $i | wc -l`; if (( $num > 1 )); then echo $num,0,$i; fi; done | heatmap > results.html
This will give you a tag cloud with files that churn more will show up larger.
I suggest using a command like
git log --follow -p file
That will give you all the changes that happened to the file in the history (including renames). If you want to get the number of commits that changed the file then you can do on a UNIX-based OS :
git log --follow --format=oneline Gemfile | wc -l
You can then create a bash script to apply this to multiple files with the name aside.
Hope it helped !
Building on a previous answer I suggest the following script to parse all project files
#!/bin/sh
cd $1
find . -path ./.git -prune -o -name "*" -exec sh -c 'git log --follow --format=oneline $1 | wc -l | awk "{ print \$1,\"\\t\",\"$1\" }" ' {} {} \; | sort -nr
cd ..
If you call the script as file_churn.sh you can parse your git project directory calling
> ./file_churn.sh project_dir
Hope it helps.